home *** CD-ROM | disk | FTP | other *** search
- #include <stream.h>
-
- class C1 {
- int x;
- public:
- void foo (int x);
- };
-
- class C2 : public C1 {
- public:
- void foo (long x);
- };
-
- void C1::foo (int x)
- {
- cout << "C1::foo()\n";
- }
-
- void C2::foo (long x)
- {
- cout << "C2::foo()\n";
- }
-
- main()
- {
- C2 cl;
- int i;
- long l;
- char c;
-
- cl.foo (i);
- cl.foo (l);
- cl.foo (c);
-
- /* Zortech calls C2::foo() for all three cases. The int is converted to a
- long rather then calling the base class's foo(). The char is converted
- to a long (which is incorrect) rather then calling the base class's foo().
- */
- /* BOTH compilers do this. It seems that the new definition hides the old
- one, rather then overloading it. */
- }
-