Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!samsung!uunet!mcsun!goya!greco.dit.upm.es!gsanchez From: gsanchez@greco.dit.upm.es (Gabriel Sanchez Gutierrez) Newsgroups: comp.lang.c++ Subject: Help about operator = . Keywords: = , assignment , Pointer to Object . Message-ID: <312@goya.dit.upm.es> Date: 27 Nov 89 11:44:19 GMT Sender: newsadm@goya.dit.upm.es Reply-To: gsanchez@greco.dit.upm.es (Gabriel Sanchez Gutierrez) Organization: Dept. Ingenieria de Sistemas Telematicos, dit, upm, Madrid, Spain Lines: 80 // I am a new C++ programmer and I have a little (??) problem with // the operator = . // This is the code : #include 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 . */