home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX1316.CPP
-
- #include <iostream.h>
-
- class base1 {
- int i;
- public:
- base1(int j = 3) : i(j) { } // constructor for base class
- int geti() { return i; } // function returns value of i
- };
-
- class derived1 : public base1 { // derived1 derived from base1
- public:
- int geti() { return 0; } // override of geti() in base1
- void printi() { cout << "Here is i " << geti() << endl; }
- };
-
- void main() {
- derived1 d; // define an object of derived1
- cout << "Here is i " << d.geti() << endl; // call base1 member
- // from object of derived1
- d.printi(); // call derived1 member
- }
-
-