From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: virtual functions Date: Mon, 07 Apr 1997 10:12:21 -0700 Organization: Alcyone Systems Lines: 33 Message-ID: <33492AF5.44A5DD15@alcyone.com> References: <860412443 DOT 3842 AT dejanews DOT com> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp tettb AT vitro DOT com wrote: > Has anybody used virtual functions in djgpp. Yes, I use them routinely. > I have a base class > declared with virtual functions. I derive a calss from this base class > in which I overide the virtual functions. When I try to link however, > any reference to these methods in the code file for the derived class > shoot out an error that looks like this: > > code.o:code.cc:undefined reference to "the virtual function as it > appears in the base class declaration" I'm not sure if I've seen this particular error with gcc before, but it sounds like you're not declaring the virtual function in the derived class with the same prototype (although in that case it should be a warning that you're masking a virtual member function). That is, if you want to have virtual member function, they must all take _exactly_ the same parameters and have _exactly_ the same return type as the original virtual member function. Otherwise you won't get the effect you're looking for. If this isn't your problem, post the smallest amount of code that reproduces it. -- Erik Max Francis, &tSftDotIotE / email: max AT alcyone DOT com Alcyone Systems / web: http://www.alcyone.com/max/ San Jose, California, United States / icbm: 37 20 07 N 121 53 38 W \ "E pur, / sic muove!" / Galileo Galilei