Answer to Question #193281 in C++ for Sarivinkumar M

Question #193281

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()

Runtime input

1356

Nitin

6


1
Expert's answer
2021-05-17T03:35:36-0400
#include <iostream>
#include <string>


using namespace std;


class Bank_ACC
{
private:
	int accno;
	string name;
public:


	virtual void get(){
		cout << "Enter account number: ";
		cin>>accno;
		cin.ignore();
		cout << "Account name: " <<this->name;
		getline(cin,name);
	}
	virtual void display(){
		cout << "Account number: " << this->accno << endl;
		cout << "Account name: " <<this->name << endl;
	}


};


class SB_ACC : public Bank_ACC
{
private:
	double roi;


public:




	void get(){
		Bank_ACC::get();
		cout << "Enter account roi: ";
		cin>>roi;
	}
	void display(){
		Bank_ACC::display();
		cout << "Roi: " << roi << endl;
	}


};


class CURR_ACC : public Bank_ACC
{
private:
	string odlimit;
public:
	void get(){
		Bank_ACC::get();
		cout << "Enter account odlimit: ";
		cin>>odlimit;
	}
	void display(){
		Bank_ACC::display();
		cout << "Oldimit is: " << odlimit << endl;
	}
};


int main()
{
	SB_ACC _SB_ACC;
	_SB_ACC.get();
	_SB_ACC.display();
	cout << endl;
	cout << endl;
	CURR_ACC _CURR_ACC;
	_CURR_ACC.get();
	_CURR_ACC.display();


	


	system("pause");
	return 0;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog