Xref: news2.mv.net comp.os.msdos.djgpp:1457 From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: "virtual outside class decl" C++ error Date: Sun, 25 Feb 1996 14:54:26 -0800 Organization: &tSftDotIotE Lines: 58 Message-ID: <3130E8A2.5BE466A0@alcyone.com> References: <199602252020 DOT PAA23382 AT twain DOT oit DOT umass DOT edu> 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 Denis P Dersarkisian wrote: > When I moved the bodies of these two virtuals into their class's declarations, > these errors went away..., however, every other method whose code wasn't within > a class declaration was reported as an error! > The same program compiles without any problems under v1.12. > Does anyone have an idea of how I can solve this problem? I'm stumped. I'm just hazarding a guess here (since I unfortunately don't have gcc 2.7.x installed on my DOS or Linux machines right now), but it looks like gcc is complaining that you declared the member function as a non-virtual member function inside the class declaration, but indicated it virtual (with the `virtual' keyword) _outside_ of the class declaration, like this: class C { public: f(); }; virtual C::f() { // ... } If this is what you're doing, what you should instead do is class C { public: virtual f(); }; C::f() { // ... } In other words, _declare_ the member function as virtual inside the class declaration, even though the function is defined outside of the class declaration. This sounds like it might be your problem; gcc 2.6.3 doesn't complain about it under Linux (so I presume it doesn't complain about it under DJGPP 1.x), even though it's something that the compiler should validly complain about. Also, your claim that the problem is fixed by declaring the member function inside the declaration makes sense, because that way you're declaring it as virtual; the fact that is defined inside the class is just incidental. Let me know if this isn't the problem; sounds like it might be what's happening, though. -- Erik Max Francis, &tSftDotIotE. && max AT alcyone DOT darkside DOT com || max AT alcyone DOT com San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade Omnia quia sunt, lumina sunt. && GIGO Omega Psi && http://www.alcyone.com/max/ "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_