onece, I also encountered this problem, finally, all went well. your code above can be compiled without any error, but if you add some other initialization into one class A(it includes "1.h"), the other class B's implementation file must also include "1.h" for the implementation of object of A in the file.
GavinWang
Posts
-
An unexplained compiler error (C2039) -
Help: How could I deal with this?as follows, what should I do? thanks:) class A { public: void f(void (*g)(int), int i) const { (*g)(i); } protected: //must be virtual, some one inherit from it virtual void g(int i) const { ; } }; class B { public: B() { pa = new A; } ~B() { delete pa; } //my problem is here: the first argument pa->g :( void fb() const { pa->f( (pa->g), 0); } private: A* pa; };
-
Help: I cannot use getline(...)thank you for the response. Finnally, I figured out the key problem. the fstream object is the data member of my class not declared mutable, but in the member function declared const, the fstream.getline() failed. //ps: the error information vc.net2003 offers me //just confuses me:(
-
Help: I cannot use getline(...)fstream file; char buffer[MAXBUFSIZE]; string line; file.open(..., ios_base::in); file.getline(buffer, MAXBUFSIZE-1); //getline(file, line); //both of the above fail to work //and the vc.net2003 print such error info: //error C2663: “std::basic_istream<_Elem,_Traits>::getline” : //2 //overloaded functions lack a legal conversion of pointer "this".