#include <iostream>
using namespace std;
class Base {
public:
virtual void show() = 0;
};
class Derived : public Base {
int i;
public:
Derived(int num) : i(num) { i = i * 2; }
void show(){cout<<i;}
};
int main() {
int n;
cin >> n;
Derived d(n);
Base &b = d;
b.show();
return 0;
}
Thanks
Happy Computing !
using namespace std;
class Base {
public:
virtual void show() = 0;
};
class Derived : public Base {
int i;
public:
Derived(int num) : i(num) { i = i * 2; }
void show(){cout<<i;}
};
int main() {
int n;
cin >> n;
Derived d(n);
Base &b = d;
b.show();
return 0;
}
Thanks
Happy Computing !
No comments:
Post a Comment