Xref: utzoo comp.lang.c++:7946 gnu.g++:888 Path: utzoo!utgpu!watserv1!watmath!uunet!mcsun!ukc!edcastle!ecsv38 From: ecsv38@castle.ed.ac.uk (S Manoharan) Newsgroups: comp.lang.c++,gnu.g++ Subject: Virtual functions under cfront 1.21 and g++ 1.37.1 Message-ID: <4566@castle.ed.ac.uk> Date: 7 Jun 90 17:53:01 GMT Reply-To: ecsv38@castle.ed.ac.uk (S Manoharan) Organization: Dept of Computer Science, University of Edinburgh Lines: 67 Consider the following code: #include class A { private: int x; protected: virtual void printx() { cout << x << "\n"; } public: A(int x1) { x = x1; } void hello() { printx(); } }; class B: public A { protected: virtual void printx() { cout << "gee, naa\n"; } public: B(int x1) : (x1) { } void greet() { printx(); } }; class C: public B { protected: virtual void printx(int x) { cout << x << "\n"; } public: C(int x1) : (x1) { } void bye() { printx(3); } }; // line 27 int main() { A a(2); B b(4); C c(8); a.hello(); b.greet(); c.bye(); return 0; } ---- <> produces the error: "prot.c", line 27: error: virtual C::printx() type mismatch: void C::(int ) and void B::() ---- g++ version 1.37.1 compiles fine and produces this result: 2 gee, naa 3 ---- I then moved the virtuals to the public area. I had the same error under cfront. And same result under g++. What is my code supposed to do? Is this a bug in g++? Thanks. -- S. Manoharan Janet: sam@uk.ac.ed.lfcs Dept of Computer Science Uucp : ..!mcsun!ukc!edcastle!lfcs!sam University of Edinburgh Arpa : sam%lfcs.ed.ac.uk@nsfnet-relay.ac.uk Edinburgh EH9 3JZ UK. Voice: 667 8323(home) 667 1018x2708(office)