犯过的错误
祥子1984
弱爆的程序员
展开
-
错误2:strcmp的返回值问题
#include #include using namespace std; class Str { public: Str( char* str):p(str){}; bool operator>(Str &str); char* p; }; bool Str::operator >(Str &str) { return(strcmp(this->p,str.p)>0);//之前此处原创 2013-04-12 14:17:02 · 2252 阅读 · 0 评论 -
错误3:对于初始化和赋值的模糊概念
class A { public: A(int a):num(a) { cout<<"Constructor"<<endl; } A(const A& a) { num = a.num; cout <<"Copy Constructor"<<endl; } A& operator=(const A& a) { num = a.num; cout <<"Opera原创 2013-04-25 11:53:57 · 357 阅读 · 0 评论 -
错误1:static初始化问题
#include using namespace std; class A { public: static int a; int c; static void seta(int b); }; int A::a = 10;//静态成员变量必须在类的内部生命,在外部定义。 void A::seta(int b) { a = b;//静态函数不可以操作非静态成员变量 } int main (原创 2013-04-12 10:56:39 · 479 阅读 · 0 评论