Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class A{
- public:
- virtual void print(){
- cout << "C" << endl;
- }
- };
- class B : public A {
- public:
- void print (){
- cout << "O" << endl;
- }
- };
- class C : public A {
- public:
- void print () {
- cout << "A" << endl;
- }
- };
- class D : public A {
- public:
- void print () {
- cout << "T" << endl;
- }
- };
- int main()
- {
- A**ptr = new A*[10];
- ptr[1] = new A();
- ptr[2] = new B();
- ptr[3] = new A();
- ptr[4] = new C();
- for(int i = 5; i < 7; i++)
- ptr[i] = new D();
- for(int i = 0; i < 10; i++)
- ptr[i] -> print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement