Develop a code for the hierarchical inheritance for banking account,
· The Bank_ACC base class consisting of data members such as accno and name, and member functions get() and display().
· The SB_ACC derived class inherited from Bank_ACC class, consisting of data members such as roi, and member functions get() and display().
· The CUR_ACC derived class inherited from Bank_ACC class, consisting of data members such as odlimit, and member functions get() and display().
#include<iostream>
using namespace std;
class Bank_ACC
{
public:
int accno;
char name;
void get();
void display()
{
cout<<"Enter the accno and name of the account holder: ";
cin>>accno>>name;
}
};
class SB_ACC : public Bank_ACC
{
public:
float roi;
void get();
void display()
{
cout<<"Enter rate of interest: ";
cin>>roi;
}
};
class CURR_ACC : public Bank_ACC
{
public:
int odlimit;
void get();
void display()
{
cout<<"Enter the limit: ";
cin>>odlimit;
}
};
int main()
{
SB_ACC obj1;
CURR_ACC obj2;
obj1.get();
obj1.display();
obj2.get();
obj2.display();
return 0;
}
Comments
Leave a comment