error:inherited member is not allowed

this is my header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef Header_H
#define Header_H
#include <iostream>
#include <string>
using namespace std;

class CurrentAccount{
	private:
		double overdraftlimit;
	public:
		CurrentAccount();
		CurrentAccount(string fName,string lName,int accno,double bal,double overd);
		void setOverdraftLimit(double overd);
		double getOverdraftLimit();  
		void display();
};

CurrentAccount::CurrentAccount(){
	overdraftlimit=0.0;
}
CurrentAccount::CurrentAccount(string fName,string lName,int accno,double bal,double overd){
	overdraftlimit=overd;
}

void CurrentAccount::setOverdraftLimit(double overd){
	overdraftlimit=overd;
}

double CurrentAccount::getOverdraftLimit(){
	return overdraftlimit;
}

void CurrentAccount::display(){
	cout<<overdraftlimit<<endl;
}

#endif 


and this one is my cpp file its not fully complete yet...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include <iostream>
#include <string>
#include "Header.h"
using namespace std;

class Account{
private:
	string firstname;
	string lastname;
	int accountnumber;
	double balance;
public:
	Account();
	Account(string fName,string lName,int accno,double bal);
	void setAccountNumber(int accno);
	void setBalance(double bal);
	void setWithdraw(int wdraw,double bal);
	void setDeposit(int dep,double bal);
	string getFullName(string fName,string lName);
	void display(string fName,string lName);

};

Account::Account(){
	firstname="Raaj";
	lastname="Lokanathan";
	accountnumber=5671;
	balance=0.0;
}

Account::Account(string FName,string LName,int accno,double bal){
	firstname = FName;
	lastname = LName;
	accountnumber = accno;
	balance = bal;
}

void Account::setAccountNumber(int accno){
	accountnumber = accno;
}

void Account::setBalance(double bal){
	balance = bal;
}

void Account::setWithdraw(int wdraw,double bal){
	if(bal>=wdraw){
		wdraw=bal-wdraw;
		cout<<"Your current balance is: "<<wdraw<<endl;
	}else{
		cout<<"No money"<<endl;
	}
}

void Account::setDeposit(int dep,double bal){
	dep=dep+bal;
	cout<<"Your current balance is: "<<dep<<endl;
}

string Account::getFullName(string fName,string lName){
	string FullName,x=" ";
	lName=x+lName;
	return FullName=fName+lName;
}

void Account::display(string fName,string lName){
	cout<<"First Name: "<<fName<<endl;
	cout<<"Last Name: "<<lName<<endl;
	cout<<"Full Name: "<<getFullName(fName,lName)<<endl;
	cout<<"Account Number: "<<accountnumber<<endl;
	cout<<"Current Balance: "<<balance<<endl;
}

class CurrentAccount:public Account{
private:
	double overdraftlimit;
public: 
	CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
		overdraftlimit=overd;
	}
	void setOverdraftLimit(double overd);
	double getOverdraftLimit();
};

void CurrentAccount::setOverdraftLimit(double overd){
	double bal;
	double wdraw;
	if(bal==0){
		if(bal>=overd){
			wdraw=bal-wdraw;
			cout<<"The revised balance is"<<wdraw<<endl;
		}else{
			cout<<"You cant access this funtion currently"<<endl;
		}
	}

double CurrentAccount::getOverdraftLimit(){
	return overd;
}

void main(){ 
	Account Acc;
	Account acc[5];
	string first_name;
	string last_name;
	int acc_no,choice,Wdraw,Dep,choice1;
	double bAl;
	int i;
	cout<<"-------------------------------"<<endl;
	cout<<"Welcome to Raaj Banking System"<<endl;
	cout<<"-------------------------------"<<endl;
	cout<<"Choose your account type below:"<<endl;
	cout<<"(1) Current Account"<<endl;
	cout<<"(2) Saving Account"<<endl;
	cout<<"Choose wisely: ";
	switch (choice1){
	case 1:
		
	for(i=0;i<5;i++){
		cout<<"Please enter the details for the customer: "<<i+1<<endl;
		cout<<"Please enter your first name: ";
		cin>>first_name;
		cout<<"Please enter your last name: ";
		cin>>last_name;
		cin.ignore();
		cout<<"Please enter your account number: ";
		cin>>acc_no;
		cout<<"Please enter your current balance: ";
		cin>>bAl;
		cout<<"----------------------------------------------------"<<endl;
		Acc.getFullName(first_name,last_name);
		Acc.setAccountNumber(acc_no);
		Acc.setBalance(bAl);
		Acc.display(first_name,last_name);
		cout<<"----------------------------------------------------"<<endl;
		cout<<"Please choose an option: "<<endl;
		cout<<"(1) Withdraw"<<endl;
		cout<<"(2) Deposit"<<endl;
		cout<<"(3) EXIT"<<endl;
		cout<<"-----------------------------------------------------"<<endl;
		cout<<"Please enter your choice: ";
		cin>>choice;
		switch(choice){
		case 1:
			cout<<"Please enter the amount you wish to withdraw: ";
			cin>>Wdraw;
			Acc.setWithdraw(Wdraw,bAl);
			break;
		case 2:
			cout<<"Please enter the amount you wish to deposit: ";
			cin>>Dep;
			Acc.setDeposit(Dep,bAl);
			break;
		case 3:
			cout<<"Try again"<<endl;
			break;
		}
	}

	system("pause");

}




the problem i m facing now is the CurrentAccount class display is showing error inherited member is not allowed..can anyone help me to solve this..
1
2
3
4
5
6
7
8
9
10
class CurrentAccount{
	private:
		double overdraftlimit;
	public:
		CurrentAccount();
		CurrentAccount(string fName,string lName,int accno,double bal,double overd);
		void setOverdraftLimit(double overd);
		double getOverdraftLimit();  
		void display();
};


1
2
3
4
5
6
7
8
9
10
class CurrentAccount:public Account{
private:
	double overdraftlimit;
public: 
	CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
		overdraftlimit=overd;
	}
	void setOverdraftLimit(double overd);
	double getOverdraftLimit();
};


Hello conflicting definitions.
how to solve this problem
Don't define a class multiple times.
One more silly code

1
2
3
4
5
6
7
8
9
10
11
void CurrentAccount::setOverdraftLimit(double overd){
	double bal;
	double wdraw;
	if(bal==0){
		if(bal>=overd){
			wdraw=bal-wdraw;
			cout<<"The revised balance is"<<wdraw<<endl;
		}else{
			cout<<"You cant access this funtion currently"<<endl;
		}
	}


Variable bal was not initialized but you compare it with zero.

if(bal==0){

There is no any sense in this code.
Topic archived. No new replies allowed.