Why am I getting these errors in this banking file?

I am working on a project for my class. Sadly, I have to take this programming class online and it has not been even close to easy. This is what I have and I cannot figure out why I keep getting the errors I am getting.



]bankingsystem.h
#ifndef BANKING_SYSTEM_H
#define BANKING_SYSTEM_H

#include <vector>
#include <iostream>
#include <string> // Used to allow string functions

using namespace std;


class Account {

public:
Account( int accountNumberValue, int passCode, string lastName, string firstName, double balance);
~Account();

void setFirstName ( string & );
string getFirstName();

void setLastName( string & );
string getLastName();

void setAccountNumber( int accountNumberValue );
int getAccountNumber();

void setPassCode( int passCodeValue );
int getPassCode();

void setBalance( double balanceValue );
double getBalance();


private:
string firstName;
string lastName;
int accountNumber;
int passCode;
double balance;

} // end class Account

#endif // Account_h

class BankingSystem
{ ---(45)
public:
BankingSystem();
~BankingSystem();

void addAccount();//option 1
Account query(int accountId);

void deleteAccount();//option 2
Account query(int accountId);

void AccountInquiry();//option 3
Account query(int accountId);

void saveAccount();//option 4
Account query(int accountId);

void loadAccounts();//option 5
Account query(int accountId);


private:
vector<Account> accounts_;

};



#endif ----(72)

[/code]


Errors:

----\bankingsystem.h(45) : error C2236: unexpected 'class' 'BankingSystem'. Did you forget a ';'?

----\bankingsystem.h(45) : error C2143: syntax error : missing ';' before '{'

----\bankingsystem.h(45) : error C2447: '{' : missing function header (old-style formal list?)

---\bankingsystem.h(72) : fatal error C1020: unexpected #endif


I am not asking anyone to debug my file...I am just asking to explain to me why this is happening. It seems so basic, maybe I am just missing something.

The lines where the errors are occurring have been made bold. And yes, that one line with the bracket is holding three errors.
Last edited on
} // end class Account should be }; // end class Account

On line 72 you have an endif, but endif makes sense in this particular case only if you have an #ifndef before. You have one at the beginning of the file, but you end it right before the Banking system class. #ifndef end #endif should come in pairs
Are these one or two separate files? If they are just one, the endif issue is because you already did endif once, after account. Also, when defining a class, you must place a ; at the end of the closing brace. In the end, it is exactly what the errors said- you did forget a semicolon, and the #endif is unexpected because you already used one.
This is just one file. I fix the errors and I thank you both for your help. But, I am running into this problem regardless of what I do. On line 7, I get an error that states "See
Account Declaration"

\bankingsystem.h(7) : see declaration of 'Account'

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
#ifndef BANKING_SYSTEM_H
#define BANKING_SYSTEM_H

#include <string> // Used to allow string functions
#include <vector>

class Account { 
public:
  Account( int accountNumberValue, int passCode, std::string lastName, 
           std::string firstName, double balance);
  ~Account();

  void setFirstName ( std::string & );
  std::string getFirstName();

  void setLastName( std::string & );
  std::string getLastName();

  void setAccountNumber( int accountNumberValue );
  int getAccountNumber();

  void setPassCode( int passCodeValue );
  int getPassCode();

  void setBalance( double balanceValue );
  double getBalance();


private:
  std::string firstName;
  std::string lastName;
  int accountNumber;
  int passCode;
  double balance;

}; // end class Account

class BankingSystem
{
public:
  BankingSystem();
  ~BankingSystem();

  Account query(int accountId);

  void addAccount();//option 1

  void deleteAccount();//option 2

  void AccountInquiry();//option 3

  void saveAccount();//option 4

  void loadAccounts();//option 5

private:
  std::vector<Account> accounts_;
};

#endif 
Last edited on
Is that the entirety of your error message? Are you sure there's not more information that your compiler's printing that you're not showing us?
Topic archived. No new replies allowed.