test.cpp:
#include <iostream>
#include <string>
using namespace std;
class Test {
private:
string str;
public:
void Setstr(const string &st);
void Getstr(string &st);
};
void Test::Setstr(const string &st) {
this->str = st;
}
void Test::Getstr(string &st) {
st = this->str;
}
int main() {
string s;
Test t();
t.Setstr("Test");
t.Getstr(s);
cout << s << endl;
return 0;
}
Result:
$ g++ -Wall -o test test.cpp
test.cpp: In function ‘int main()’:
test.cpp:25:4: error: request for member ‘Setstr’ in ‘t’, which is of non-class type ‘Test()’
t.Setstr("Test");
^
test.cpp:26:4: error: request for member ‘Getstr’ in ‘t’, which is of non-class type ‘Test()’
t.Getstr(s);
^
Well?