creating an inheritance hierarchy that a bank might use to represent customers'bank account

//BankingSystem.cpp
#include<iostream>
#include<string>

using namespace std;

class Account
{
private:
public:
Account();//default constructor
Account(int initialBalance){dataMember = initalBalance;
};
//constructor with parameter

int main()
{

return 0;

#ifndef account
#define Account_H
double credit, debit, balance;
class Account
{
private :
string name, phone_number, address;
char gender;

public:
void setName(string);
void setGender(char);
void setphone_number(string);
void setAddress(string);
void setCredit(double);
void setDebit(double);
void setBalance(double);
string getName();
string setphone_number();
string setAddress();
char getGender();
double getCredit();
double getDebit();
double getBalance();
};
#endif
//SavingsAccount.h

class SavingsAcount:public Account
{
private:
double interest_rate;
public:
setInterest_rate(double);
double getInterest_rate();
}
//CheckingAcount.h


class ChechingAcount:public Account
{
private:
double Fee_charged;
public:
setfee_charged(double);
double getFee_charged();

}


i have done everything so far but it is giving me just one error message saying end of file before left braces. pls can someone take a look at it for me plsssss
You need to have a semicolon after the closing brace of a class declaration.

Edit:

Please always use code tags - the <> button on the right you should know that by now with 24 posts.

It is not a good idea to have public get / set functions for each private member of a class. You might as well make all the members public!!!

Instead think about what actual operations you are going to do on the object? For example you could have a GetInput function that sets all the variables in one go. You also have constructors. You might also have a display function that prints out all the variable values.
Last edited on
pls can you tell me what line is that. pls
IF you had code tags then I could do that.
//BankingSystem.cpp
#include<iostream>
#include<string>

using namespace std;

class Account
{
private:
public:
Account();//default constructor
Account(int initialBalance){dataMember = initalBalance;
}
//constructor with parameter

int main()
{

return 0;

#ifndef account
#define Account_H
double credit, debit, balance;
class Account
;{
private :
string name, phone_number, address;
char gender;

public:
void setName(string);
void setGender(char);
void setphone_number(string);
void setAddress(string);
void setCredit(double);
void setDebit(double);
void setBalance(double);
string getName();
string setphone_number();
string setAddress();
char getGender();
double getCredit();
double getDebit();
double getBalance();
};
#endif
//SavingsAccount.h

class SavingsAcount:public Account
;{
private:
double interest_rate;
public:
setInterest_rate(double);
double getInterest_rate();
};
//CheckingAcount.h


class ChechingAcount:public Account
;{
private:
double Fee_charged;
public:
setfee_charged(double);
double getFee_charged();

};
i code tag it if lm right. pls and thanks
No, you put the code tags first, then I will show where it is still wrong.
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
//BankingSystem.cpp
#include<iostream>
#include<string>

using namespace std;

class Account
{
private: 
public:
	Account();//default constructor
	Account(int initialBalance){dataMember = initalBalance;
}
	//constructor with parameter

int main()
{	

	return 0;

#ifndef account
#define Account_H
double credit, debit, balance;
class Account
;{
private :
	string name, phone_number, address;
	char gender;
	
public:
	void setName(string);
	void setGender(char);
	void setphone_number(string);
	void setAddress(string);
	void setCredit(double);
	void setDebit(double);
	void setBalance(double);
	string getName();
	string setphone_number();
	string setAddress();
	char getGender();
	double getCredit();
	double getDebit();
	double getBalance();
};
#endif
//SavingsAccount.h

class SavingsAcount:public Account
;{
private:
	double interest_rate;
public:
	setInterest_rate(double);
	double getInterest_rate();
};
//CheckingAcount.h


class ChechingAcount:public Account
;{
	private:
		double Fee_charged;
		public:
		setfee_charged(double);
		double getFee_charged();

};
1
2
3
4
5
6
7
8
class SavingsAcount : public Account  { //deleted ;
private:
	double interest_rate;
public:
	setInterest_rate(double);
	double getInterest_rate();
};  //keep this one


You nearly had it. As I said - need semicolon after the closing brace. You added one before the opening brace as well.

To work this out yourself - read the documentation / reference section at the top left of this page.
thank you i did all but the only error it says is the last line error code 1075, ie end of file found before left braces.
l appreciate your time for helping
1
2
3
4
5
6
7
8
class Account
{
private: 
public:
	Account();//default constructor
	Account(int initialBalance){dataMember = initalBalance;
}
	//constructor with parameter 


Is there still a problem with this? There is a mismatch with something.

If you are using an IDE, you can set it up to take care of matching braces, parentheses etc. You should also be able to get it to create classes for you as well.
thanks alot for replying, it is not just debugging, still saying end of file. l tried rewriting it using another textbook and a link a friend gave me, still same thing. l am using visual basic c++, empty console as directed. let me paste what l did this morning again, l have not slept since yesterday.


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
#include<iostream>
#include<string>
using namespace std;

class Account

{
private: 
public:
	Account();//default constructor
	Account(int initialBalance){
		dataMember = initalBalance

	//constructor with parameter



int main()
{	
	int initial_balance=50.00;

	
	CheckingAccount my_checking_account=(CheckingAccount)new Account(initial_balance);
	my_checking_account.setName("SirNeeds AlotOfPractice");
	my_checking_account.setGender("M");
	my_checking_account.set_Fee_charged(2.5);
  
	cout << "Account info: " << endl;
	cout << "\tName: " << my_checking_account.getName() << endl;
	cout << "\tGender: " << my_checking_account.getGender() << endl;
	cout << "\tBalance: " << my_checking_account.getBalance() << endl;
	cout << "\tChecking Account Fee: " << my_checking_account.get_Fee_charged() << endl;
	return 0; // return 0 to report no errors.
}

// ----------------------------------------------------------

void Account::setName(string name) {
	this.name=name;  // "this""name"
	
}
string Account::getName() {
	return this.name;
}

void Account::setGender(char gender) {
	this.gender=gender
}
char Account::getGender() {
	return this.gender;
}
 double Account::getBalance() {
	 return this.balance;
 }
 void CheckingAccount::set_Fee_charged(double fee) {
	 this.Fee_charged=fee;
 }
 void CheckingAccount::get_Fee_charged() {
	 return this.Fee_charged;
 } 

// Account.h
#ifndef Account_H
#define Account_H

 class Account
 {
 private :
	 string name, phone_number, address;
	 char gender;
	 double credit, debit, balance;
	 
 public: 
{
		 // default constructor, 	
}
		 Account(double initial_balance);
		 
{
			 this.balance=initial_balance;		 
}
	void setName(string);
	void setGender(char);
	void setphone_number(string);
	void setAddress(string);
	void setCredit(double);
	void setDebit(double);
	void setBalance(double);
	string getName();
	string setphone_number();
	string setAddress();
	char getGender();
	double getCredit();
	double getDebit();
	double getBalance();
 }

#endif 
//SavingsAccount.h 
 class SavingsAcount : public Account  {
 private:
	 double interest_rate;
 public:
	 setInterest_rate(double);
	 double getInterest_rate();
 }

 
//CheckingAcount.h

 class ChechingAcount:public Account {
 private:
	 double Fee_charged;
 public:
	 set_Fee_charged(double);
	 double get_Fee_charged();
	 
 } 
closed account (1yR4jE8b)
Like somebody already mentionned, you don't have semi-colons ; at the end of your classes:

1
2
3
4
5
6
7
8
class ChechingAcount:public Account {
 private:
	 double Fee_charged;
 public:
	 set_Fee_charged(double);
	 double get_Fee_charged();
	 
 }; // <<<<<<<<<<<<<<--------------- here  
hi darkestfright,
thank you for taking your time to reply me. l do have it on,i did rectified it last night, the only error is the end of file directory.
if you dont mind, let me paste it below pls

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
#include<iostream>
#include<string>
using namespace std;

class Account

{
private: 
public:
	Account();//default constructor
	Account(int initialBalance){
		dataMember = initalBalance

	//constructor with parameter



int main()
{	
	int initial_balance=50.00;

	
	CheckingAccount my_checking_account=(CheckingAccount)new Account(initial_balance);
	my_checking_account.setName("SirNeeds AlotOfPractice");
	my_checking_account.setGender("M");
	my_checking_account.set_Fee_charged(2.5);
  
	cout << "Account info: " << endl;
	cout << "\tName: " << my_checking_account.getName() << endl;
	cout << "\tGender: " << my_checking_account.getGender() << endl;
	cout << "\tBalance: " << my_checking_account.getBalance() << endl;
	cout << "\tChecking Account Fee: " << my_checking_account.get_Fee_charged() << endl;
	return 0; // return 0 to report no errors.
}

// ----------------------------------------------------------

void Account::setName(string name) {
	this.name=name;  // "this""name"
	
}
string Account::getName() {
	return this.name;
}

void Account::setGender(char gender) {
	this.gender=gender
}
char Account::getGender() {
	return this.gender;
}
 double Account::getBalance() {
	 return this.balance;
 }
 void CheckingAccount::set_Fee_charged(double fee) {
	 this.Fee_charged=fee;
 }
 void CheckingAccount::get_Fee_charged() {
	 return this.Fee_charged;
 } 

// Account.h
#ifndef Account_H
#define Account_H

 class Account
 {
 private :
	 string name, phone_number, address;
	 char gender;
	 double credit, debit, balance;
	 
 public: 
{
		 // default constructor, 	
}
		 Account(double initial_balance);
		 
{
			 this.balance=initial_balance;		 
}
	void setName(string);
	void setGender(char);
	void setphone_number(string);
	void setAddress(string);
	void setCredit(double);
	void setDebit(double);
	void setBalance(double);
	string getName();
	string setphone_number();
	string setAddress();
	char getGender();
	double getCredit();
	double getDebit();
	double getBalance();
 }

#endif 
//SavingsAccount.h 
 class SavingsAcount : public Account{
 private:
	 double interest_rate;
 public:
	 setInterest_rate(double);
	 double getInterest_rate();
 }

 
//CheckingAcount.h

 class ChechingAcount:public Account {
 private:
	 double Fee_charged;
 public:
	 set_Fee_charged(double);
	 double get_Fee_charged();
	 
 }; 
Topic archived. No new replies allowed.