在《C++ Primer》的13.5节的动态内存管理类中,一旦将allocator设为静态成员,编译时就会报错。
class StrVec{
/* other code */
private:
static allocator<string> alloc;
}
错误原因在下面
操作系统window10,书上的代码是有static的。
为什么会这样的?谢谢。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
类里的static成员只是声明,还要在类外进行定义。
在某个cpp文件里加上: