I am trying to compile an object file using the code below.
//--Begin test.cpp
class A;
void (A::* f_ptr) ();
void test() {
A *a;
(a->*f_ptr)();
}
//-- End test.cpp
For GNU g++ compiler, it is able to compile the object file.
$ g++ -c test.cpp
But for Sun Studio 12 on a Solaris 10 (SPARC), it outputs an error.
$ CC -c test.cpp
"test.cpp", line 7: Error: Cannot call through pointer to member function before defining class A.
1 Error(s) detected.
Is there a compiler flags to get the Sun Studio C++ compiler to build the object file? Is there another workaround?