davew@panache.cs.umd.edu (David G. Wonnacott) (03/27/91)
A year or two ago, I found out that if a derived class provided a function of the same name as a base class function, but with incompatible argument types, cfront did not allow the use of the base class function on derived class objects. That is, the comments in the program below were correct, and it did not compile. I find that with g++, the program below DOES compile. Is this yet another difference between g++ & cfront, or has there been a change in cfront? What is the "correct" behavior of a C++ compiler according to the ARM (I don't have mine handy)? David Wonnacott class super { public: void func(int i); }; class not_subtype : public super { public: void func(char *s); }; demento() { super y; not_subtype x; y.func(4); x.func("hello"); x.func(4); // ILLEGAL x.func(char *) prevents use of x.func(int) super *look_like_super; look_like_super = &x; (*look_like_super).func(4); // OK } -- David Wonnacott davew@tove.cs.umd.edu Although the moon is smaller than the earth, it is further away.