我在课堂上遇到了一些麻烦.
#include <vector>
using namespace std;
class sth {
vector<int> tab();
public:
void add(int i);
};
void sth::add(int i){
tab.push_back(i);
}
int main() {
sth a;
a.add(10);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这个简单的代码导致11 5 [Error] '((sth*)this)->sth::tab' does not have class type
任何想法发生了什么?