C++编译器报错汇总


1.error: ‘Person’ was not declared in this scope
(1)若是一个类或函数的命名空间对使用者不可见
(2)成员(静态)函数没有通过对象名或类名进行调用
(3)虽然指定了命名空间,但是没有包含头文件

2.‘Point’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
(1)重载时没有使用const: eg ostream& operator<<(ostream &o, Point &p); Point &p前加const解决。原因:因为表达式n++返回的是无名临时对象,只能用const引用指向。

猜你喜欢

转载自www.cnblogs.com/hellokitty2/p/10587670.html