Wisdom Materials
Home
About Us
Our Clients
Careers
Services
Education
Jobs
News
Business
Health
Astrology
Entertainment
RealEstate
Devotion
Contact Us
CPP Programs
/ CPP Program to Create an Array of Pointers and Invoke Functions
Program Name
CPP Program to Create an Array of Pointers and Invoke Functions
Program Code
Copy Program
#include
class A { public: virtual void show() { cout<<"A\n"; } }; class B : public A { public: void show() { cout<<"B\n"; } }; class C : public A { public: void show() { cout<<"C\n"; } }; class D : public A { public: void show() { cout<<"D\n"; } }; class E : public A { public: void show() { cout<<"E"; } }; void main() { A a; B b; C c; D d; E e; A *pa[]={&a,&b,&c,&d,&e}; for(int j=0;j<5;j++) pa[j]->show(); }
Input
Output
A B C D E
Home
Back