该代码无法运行。我正在使用CodeBlocks。
我刚刚学习了如何创建类并访问它们, 我是c ++的新手
#include <iostream>
using namespace std;
class Bclass(){
public:
void print(){
cout << "h" << endl;
}
};
int main(){
Bclass c;
c.print();
return 0;
}
I expected the screen to print "h" but it didn't work.
Error results:
/Users/jo/Desktop/classes/main.cpp|4|error: expected unqualified-id|
/Users/jo/Desktop/classes/main.cpp|12|error: variable has incomplete type 'Bclass'|
/Users/jo/Desktop/classes/main.cpp|4|note: forward declaration of 'Bclass'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
答案 0 :(得分:1)
从类BClass的前面删除()。