Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- class BaseClass {
- public:
- BaseClass() {}
- virtual void print() {
- cout << "base class" << endl;
- }
- };
- class DerivedClass : public BaseClass {
- public:
- DerivedClass(){}
- void print()
- { cout << "derived class" << endl;
- }
- };
- int main(){
- BaseClass *b = new DerivedClass();
- b->print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement