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