Originally posted by M.shawan
class abc
{
private:
int x; // you have not initial x direct with 99.
public:
abc() { x=99;} // constrctur initial the member x with 99.
int get_x() { return x; }
};
//The content of second.cc is:
#include <iostream.h> // syntax error"iostresm"
extern class abc test_abc;
int main() {
abc test_abc; // create an test_abc object.
cout << test_abc.get_x() << endl;
return (0);
}
Thanks. But if you have read my second message, you would know that I have used iostream already.
Now, your suggestion creates an error when compiling second.cc:
" In function 'int main()' :
aggregate 'class abc test_abc' has incomplete type and cannot
be initialized. "
So, any other suggestions? =(
P.S. extern.... It drive me crazy, how to use it with class object?