#include<iostream> #include<vector> class Account { public: virtual void PrintBalance() { std::cout<<"Base"<<std::endl; } }; class SavingAccount : public Account { public: void PrintBalance() { std::cout<<"SavingAccount"<<std::endl; } }; int main() { 1)Account* p = new SavingAccount(); p->PrintBalance(); 2)Account* p1 = new Account(); p1->PrintBalance(); 3)SavingAccount *p3 = new Account(); p3->PrintBalance(); 4)SavingAccount* p4 = new SavingAccount(); p4->PrintBalance(); return 0; };
C++
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)