gsanchez@greco.dit.upm.es (Gabriel Sanchez Gutierrez) (11/27/89)
// I am a new C++ programmer and I have a little (??) problem with // the operator = . // This is the code : #include <stdio.h> class T { int t ; T* next ; public : T(int) ; ~T() ; // His contenst void print1(void); T& operator = (T&) ; }; T::T ( int val ) { t = val ; if (--val) next = new T (val); else next = 0; } T& T::operator= (T& tt) { return (*this); // It's enough for this test . } void T::print1(void) { T* other = this ; printf("\n\n"); do printf("%d ",other->t); while (other=other->next); } /**** In Zortech C++ 1.06 - the last version I have - , this fragment compiles good . Only complains with a warning in >> print1 : other = other->sigo >> Warning : possible unintended assignment but I think it is not very important . My principal problem is with GNU g++ . In three lines , it gives errors : >> Constructor : next = new T (val) next = 0 >> print1 : other = other->sigo He tells me to miss parameters for the constructor . The errors are In method T::T (int): 25: bad argument list for method `operator =' 27: bad argument list for method `operator =' In method T::print1 (): 45: bad argument list for method `operator =' I want to do an assignment between pointer to T , not between objects of type T . Do I forget something important ? Is my error an basic error ? Thanks . */