Create a base class, Telephone
, and derive a class ElectronicPhone
from it. In Telephone
, create a protected string
member phonetype
, and a public
method Ring( )
that outputs a
text message like this: “Ringing the <phonetype>.” In
ElectronicPhone
, the
constructor should set the phonetype
to “Digital.” In the Run( )
method, call Ring( )
on the ElectronicPhone
to test the
inheritance.
Extend Exercise 11-1 to illustrate a polymorphic method.
Have the derived class override the Ring( )
method to display a different message.
Change the Telephone
class to abstract, and make Ring( )
an abstract method. Derive two new classes from
Telephone
: DigitalPhone
and TalkingPhone
. Each derived class should
set the phonetype
, and override
the Ring( )
method.