static field problems

Hello all,

Im getting the following error for the attached code..I believe line 28 in the code is causing the problems..

PersonProblem_09_3a.cpp:28: error: extraneous `int' ignored
PersonProblem_09_3a.cpp:28: error: conflicting declaration 'Account Account::nextAccountNumber'
PersonProblem_09_3a.cpp:12: error: 'Account::nextAccountNumber' has a previous declaration as `int Account::nextAccountNumber'

PersonProblem_09_3a.cpp:54: error: no `void Account::dislplay()' member function declared in class `Account'
PersonProblem_09_3a.cpp: In member function `virtual bool Account::makeWithdrawal(float&)':
PersonProblem_09_3a.cpp:64: error: stray '`' in program
PersonProblem_09_3a.cpp: In constructor `CurrentAccount::CurrentAccount(float, std::string, float)':
PersonProblem_09_3a.cpp:72: error: class `CurrentAccount' does not have any field named `balance'
PersonProblem_09_3a.cpp:72: error: class `CurrentAccount' does not have any field named `owner'
make.exe: *** [PersonProblem_09_3a.o] Error 1

Execution terminated


Someone help please?

Thanks
#include <iostream>
#include <string>

using namespace std;

class Account
{
 protected:
  float balance;
  int accountNumber;
  string owner;
  static int nextAccountNumber;
  
 private:
  void construct(float, string);

 public:
  Account(float, string);
  Account(float);
  Account();
  
  virtual void display();
  virtual bool makeWithdrawal(float &);
  virtual void makeLodgement(float &);
  
} 
  
  int Account::nextAccountNumber = 12345;
   
class CurrentAccount: public Account
{
  float overdraftLimit;
  
 public:
  CurrentAccount(float, string, float);
  CurrentAccount(Account, float);
  virtual void display();
  virtual bool makeWithdrawal(float &);
};

 Account::Account(float _balance, string _owner):balance(_balance),
   owner(_owner){}
   
  Account::Account(float _balance):balance(_balance){}
  
  Account::Account(){}
  
  void Account::construct(float _balance, string _owner){
       accountNumber = nextAccountNumber++;
       balance = _balance;
       owner = _owner;      
       }
       
  void Account::dislplay(){
       cout<<"Account owned by " << owner << " , account number: " 
       << accountNumber << " , balance : " << balance << endl;
       }
       
  bool Account::makeWithdrawal(float& amount){
       if (balance > amount){
           balance = balance - amount;
           return true;}
       else   
           return false;`
       }
  
  void Account::makeLodgement(float& amount){
       balance = balance + amount;
       }

  CurrentAccount::CurrentAccount(float _balance, string _owner, 
  float _overdraftLimit):balance(_balance), owner(_owner), overdraftLimit
  (_overdraftLimit){}
  
  CurrentAccount::CurrentAccount(Account a, float _overdraftLimit):
                  Account(a), overdraftLimit(_overdraftLimit){}
                  
  void CurrentAccount::display(){
    Account::display();
    cout << "And overdraft limit: " << overdraftLimit << endl;}
     
  bool CurrentAccount::makeWithdrawal(float &amt){
       if (amt<=(balance+overdraftLimit)){
           balance-=amt;
           return true;}
           
       else return false;
}

int main()
{
  Account a(100.0f, "Derek Molloy");
  CurrentAccount b(200.0f, "John Doe", 500.0f);
  CurrentAccount c(a, 1000.0f);
  a.display();
  b.display();
  c.display();
  system("pause");
}

Open in new window

oggiemcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

evilrixSenior Software Engineer (Avast)Commented:
You are missing a semi colon off the end of your class definition at line 26. Incidentally, the definition of a static needs to go into a .cpp file, you can't have it in the header otherwise it'll generate errors about duplicate definitions if included in more than once translation unit.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Infinity08Commented:
You forgot the ; at the end of the Account class definition:
class Account {
    // <SNIP>
};                              // <--- this one

Open in new window

Infinity08Commented:
heh :)
oggiemcAuthor Commented:
Thanks guys..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.