hello, I kep getting :

C:\computer science programming\excerise sheet 6\cheque account\3 - Bank.cpp(100) : error C2614: 'cheque' : illegal member initialization: 'Balance' is not a base or member
Error executing cl.exe.

#include <iostream>

using namespace std;

class BankAccount
{
public:
//void setAccount(int num, double amount); taken out replaced by constructor
   BankAccount( double amount);
   BankAccount(); // def constructor
int getBalance();
int getAccountNumber();
void deposit(double AnAmount);
void withdraw(double AnAmount);

static int getTotal();


protected:
int accountNumber;
int Balance;

static int numOfAccounts;

};



class cheque : public BankAccount 
{
public:
cheque(double amount, double rate);
   double getintrestRate()
   {
      return intrate;
   }
double Calintrest()
{
   if (Balance > 0.0)
      return intrate * Balance;
   return 0.0;
}

private:

double intrate;


};

BankAccount::BankAccount()
{  
     Balance = 0;
     accountNumber = 100;
}  

/*void BankAccount::setAccount(int num, double amount)
{
accountNumber = num ;
Balance = amount ;
}*/

int BankAccount::numOfAccounts = 0;

int BankAccount::getTotal()
{
   return numOfAccounts;
}

BankAccount::BankAccount( double amount)
{
   numOfAccounts +=1000;
   accountNumber = numOfAccounts;
   Balance = amount ;
}


int BankAccount::getBalance()
{
   return Balance;
}

int BankAccount::getAccountNumber()
{
   return accountNumber;
}


void BankAccount::deposit(double AnAmount)
{
   Balance += AnAmount;
}

void BankAccount::withdraw(double AnAmount)
{
   Balance -= AnAmount;
}

cheque::cheque( double amount ,double rate):Balance(amount),intrate(rate)
{
}

int main()
{

   BankAccount myAcct( 500); //call to constructor

   
   cout << "my Account constructed" << endl;
   cout << "Account Number: " << myAcct.getAccountNumber() 
        << " Which as a balance of : " << myAcct.getBalance() << endl;

   myAcct.deposit(300);

   cout << "After deposting 300 , the balance is now " <<   myAcct.getBalance() 
        <<endl;

   myAcct.withdraw(600);

   cout << "The balance after withdrawing over 600.00 is now : "
         << myAcct.getBalance() <<endl;

   BankAccount poorStudent(100);
   cout << "poorStudent account constructed" << endl;
   cout << "Account Number:" << poorStudent.getAccountNumber();

   return 0;
}

i cant figure it out :rolleyes:

pants sorted it! Guess what! I was trying to some how set a member rather than invoke the constructor, it should be:

cheque::cheque( double amount ,double rate):BankAccount(amount)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.