#include <iostream>
using namespace std;
class A {
protected:
int i;
public:
A(int a = 0) : i(a) {}
void fun() { cout << i; }
};
class B :public A{
public:
B(int a = 0) : A(a) {}
virtual void fun() { cout << i*10; }
};
class C :public B{
public:
C(int a = 0) : B(a) {}
virtual void fun() { cout << i*15; }
};
int main(){
int num;
cin >> num;
B *bp = new C(num);
bp->fun();
return 0;
}
Thanks
Happy Programming !
using namespace std;
class A {
protected:
int i;
public:
A(int a = 0) : i(a) {}
void fun() { cout << i; }
};
class B :public A{
public:
B(int a = 0) : A(a) {}
virtual void fun() { cout << i*10; }
};
class C :public B{
public:
C(int a = 0) : B(a) {}
virtual void fun() { cout << i*15; }
};
int main(){
int num;
cin >> num;
B *bp = new C(num);
bp->fun();
return 0;
}
Thanks
Happy Programming !
ReplyDeleteYou can certainly see your expertise within the article you write. The arena hopes for even more passionate writers like you who aren’t afraid to mention how they believe. All the time go after your heart.
IGNOU Courses
IGNOU Study Material
IGNOU Syllabus
IGNOU Assignments
IGNOU Study Center
IGNOU MBA Study Material