From: david DOT stegbauer AT cz DOT opel DOT com X-Lotus-FromDomain: GMCZECHIA AT EDSHUBEUROPE Sender: david DOT stegbauer AT cz DOT opel DOT com To: s257m AT unb DOT ca cc: djgpp AT delorie DOT com Message-ID: <41256730.00478CB3.00@derumg01.cyberlink.eds.com> Date: Wed, 10 Mar 1999 14:05:34 +0100 Subject: Re: GCC thinks there is an error when I don't. Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Content-Disposition: inline Reply-To: djgpp AT delorie DOT com Endlisnis wrote: > I get this error when I compile the code given. >In function `int main(int, char **)': >t.cc(26) Error: request for member `Data' in `b.List::Current()()', which >is of non-aggregate type `int' >---- >template >class Node >{ > public: > T Data; > }; > >template >class List >{ > Node* Curr; > > public: > T Current(); > }; > >int main(int argc, char *argv[]) >{ > List b; > int c = b.Current().Data; > /*Note this line. It is assigning an 'int' to an 'int', but the compiler >gets an error. */ > return 0; >} > >template >T List::Current() >{ > return Curr->Data; > } In noted line you are really referencing `Node::Data.Data' (see? `Data' is referenced twice). But `Data' is int (in your example). the right line should be int c = b.Current(); or you should change definition of List::Current not to return T but Node& (or Node for const method version). David