共 2 篇文章 |
|
类中的static成员对象,调用时显示未定义类中的static成员对象,调用时显示未定义 ##### a.h #######class A{public: static int a; //其他} ##### a.cpp ########include "a.h"//成员函数的定义 ##### main.cpp ########include "a.h"A a1;a1.a = 10; 错误:编译时显示a未定义; 阅267 转0 评0 公众公开 11-11-02 16:22 |
在使用g++编译时会出现如下错误:test.cpp: In function ‘int main()’:test.cpp:28: 错误:将 ‘const A’ 作为 ‘std::string A::ToString()’ 的 ‘this’ 实参时丢弃了类型限定 出现错误的原因是因为STL在指向set的内容时为const类型(是不可更改的),所以strset.begin()其实对应的是一个const A类型,而ToString()方法不能保证这strs... 阅3035 转0 评0 公众公开 11-11-02 15:45 |