This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C4A53A.DFC9D850
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
The 4th line in my main method in the code below does not compile.
Isn't there a way to overload a base class method in the derived class =
in C++?
I know C#, java and VB.NET allow this.
TIA
Sankar Nemani
class B
{
public:
void foo(){}
=20
};
class D: public B
{
public:
void foo(int i){}
};
void main()
{
B *b =3D new B();
D *d =3D new D();
b->foo();
d->foo(); //does not compile
}
------=_NextPart_000_0008_01C4A53A.DFC9D850
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.3790.186" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>The 4th line in my main method in the =
code below=20
does not compile.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Isn't there a way to overload a base =
class method=20
in the derived class in C++?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I know C#, java and VB.NET allow=20
this.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>TIA</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Sankar Nemani</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>class B<BR>{<BR>public:<BR> void=20
foo(){}<BR> <BR>};</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>class D: public =
B<BR>{<BR>public:<BR> void=20
foo(int i){}<BR>};</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>void main()<BR>{<BR> B *b =3D new=20
B();<BR> D *d =3D new=20
D();<BR> b->foo();<BR> <STRONG>d->foo(); //does not=20
compile<BR></STRONG>}</FONT></DIV></BODY></HTML>
------=_NextPart_000_0008_01C4A53A.DFC9D850--