home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_02_09
/
2n09065a
< prev
next >
Wrap
Text File
|
1991-07-26
|
654b
|
34 lines
// VIRTUAL.L - Demonstrate all member functions are virtual.
class base
{
print() { w << "Base class\n"; }
print2() { print(); }
baseprint() { base::print(); }
};
class derived : base
{
print() { w << "Derived class\n"; }
};
main() {
w = new textwindow ("base vs. derived");
w.show();
base b = new base;
derived d = new derived;
w << "b.print():";
b.print();
w << "b.print2():";
b.print2();
w << "b.baseprint():";
b.baseprint();
w << "d.print():";
d.print();
w << "d.print2():";
d.print2();
w << "d.baseprint():";
d.baseprint();
}