Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!godzilla!kohlrabi!robert From: robert@kohlrabi.tcs.com (Robert Blumen) Newsgroups: comp.lang.c++ Subject: Re: Virtual function problem. Keywords: C++ virtual function Message-ID: <2164@godzilla.tcs.com> Date: 9 May 91 20:31:05 GMT References: <3472@trlluna.trl.oz> Sender: root@tcs.com Reply-To: robert@kohlrabi.tcs.com (Robert Blumen) Organization: Teknekron Communications Systems Lines: 32 In article <3472@trlluna.trl.oz>, mcf@tardis.trl.OZ.AU (Michael Flower) writes: |> If I compile the following with the AT&T 2.1 C++ compiler: |> |> class A { |> virtual void fn(char); // 1 |> virtual void fn(char *); // 2 |> }; |> |> class B : public A { |> void fn(int); |> }; |> |> in the following way, I get. |> |> "t.c", line 7: warning: B::fn() hides virtual A::fn() |> "t.c", line 7: warning: B::fn() hides virtual A::fn() |> |> Of course B::fn() hides A::fn(). That is why I wrote it! After all A::fn() |> is virtual. The message means that B::fn hides A::fn() and the compiler is wondering whether perhaps you want B::fn to override A::fn() instead. I am not sure why the message goes away when you reverse 1. and 2. This may have something to do with what implicit type conversion gets performed. If you want B::fn() to override A::fn() for 1. or 2., you must declare it with exactly the same prototype. ----------------------------------------------------------------------------- Robert Blumen | rblumen@tcs.com Senior Software Engineer | 2121 Allston Way, Berkeley, CA 94704 Teknekron Communications Systems, Inc. | (415) 649-3759