在《C++ Primer》的13.5节的动态内存管理类中,一旦将allocator设为静态成员,编译时就会报错。
class StrVec{
/* other code */
private:
static allocator<string> alloc;
}
错误原因在下面
操作系统window10,书上的代码是有static的。
为什么会这样的?谢谢。
在《C++ Primer》的13.5节的动态内存管理类中,一旦将allocator设为静态成员,编译时就会报错。
class StrVec{
/* other code */
private:
static allocator<string> alloc;
}
错误原因在下面
操作系统window10,书上的代码是有static的。
为什么会这样的?谢谢。
3 回答1.1k 阅读✓ 已解决
2 回答1.4k 阅读✓ 已解决
1 回答983 阅读✓ 已解决
4 回答773 阅读
1 回答852 阅读
1 回答884 阅读
1 回答650 阅读
类里的static成员只是声明,还要在类外进行定义。
在某个cpp文件里加上: