class Foo
{
public:
Foo() {};
Foo(int a) {};
void bar() {};
};
int main()
{
// this works...
Foo foo1(1);
foo1.bar();
// this does not...
Foo foo2();
foo2.bar();
return 0;
}
ER MSG:
nonclass.cpp: In function ‘int main(int, const char**)’:
nonclass.cpp:17: error: request for member ‘bar’ in ‘foo2’, which is of non-class type ‘Foo ()()’
Correct:
Foo foo2;
Compiler think the declaration Foo foo2() is not a constructor. Instead, it is a function "foo2()" which return class FOO.
Therefore, when we are going to access the member function, bar, we "request for member"bar" in foo2但foo2 is of non-class type"
Some similar error msg
error: request for member 'computeLog2Det' in '((ULSA3a*)this)->ULSA3a::matrixComputer', which is of non-class type 'CORRE_MA_OPE*'|
when matrixComputer is declared as CORRE_MA_OPE* matrix computer
and we use in matrixComputer.computeLog2Det(1.0,cSystem->allSupStru);
沒有留言:
張貼留言