ecsv38@castle.ed.ac.uk (S Manoharan) (06/08/90)
Consider the following code: #include <stream.h> 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; } ---- <<cfront 1.2.1 2/16/87>> 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)