目录ios
CLRead read_buff()
就是一种错误的构造,致使read_buff没法被识别, 出现note: no known conversion for argument 1 from ‘CLRead (*)()’ to ‘CLRead*’
;// 错误 #define FILE_H #include "file.h" #endif // 正确 #define FILE_H #include "myfile.h" #endif class CLFileBuff; // 声明后才能使用,要否则也会出现这类错误
参考资料
error: expected ')' before '*' tokenc++
// 错误 char* prt; prt = str; // 正确 char* prt; prt = (char*)str;
// 错误 // file: C.h class C{ }; // file: main #include "C.h" static class C; ... ... // 正确 // file: C.h class C{ }; // file: main #include "C.h" class C; ... ...
// 错误 class C{ int func(){} }; int c = C::func(); ... ... // 正确 class C{ int func(){} }; C temp; int c = temp.func(); ... ...
// 错误 class C{ int a; int &r; C(); }; C::C(){ a = 1; } ... ... // 正确 class C{ int a; int &r; C(); }; C::C():r(a){ a = 1; } ... ...
// 错误 #include<iostream> class C{ private: int a; public: bool func(){ cout << "hello: " << this->a << endl; } C(const C& c){ c.func(); } }; C c1; C c2(c1); // 正确 #include<iostream> class C{ private: int a; public: bool func() const{ cout << "hello: " << this->a << endl; } C(const C& c){ c.func(); } }; C c1; C c2(c1);
参考资料
error: passing 'const …' as 'this' argument of '…' discards qualifiers
error:passing 'const Student' as 'this' argument of 'void Student::print()' discards qualifiersexpress
// 错误 class C{ C(int a=1); } C::C(int a=1){;} // 正确 class C{ C(int a=1); } C::C(int a){;} };
// 错误 class C{ ... ... } // 正确 class C{ ... ... };
#ifdef ×××× //定义一个宏,一般是该头文件名大写 #define ×××× #endif
// 定义C类 // 错误 C{ ... ... }; // 正确 class C{ ... ... };
// 错误 // file: C.h class C{ ... ... }; // file: test.h #include "C.h" C test; ... ... // 正确 // file: C.h class C{ ... ... }; // file: test.h #include "C.h" class test; C test; ... ...
// 错误 class C{ virtual C(); }; virtual C(){ ... ... } // 正确 class C{ virtual C(); }; C(){ ... ... }
// 错误 const char* pathname = "hello.txt"; oflag = O_RDWR|O_APPEND; this->_fd = open(const char* pathname, int oflag); // 正确 const char* pathname = "hello.txt"; oflag = O_RDWR|O_APPEND; int fd = open(pathname, oflag);