Im trying to make a program that has a base class Account and a class ,Savings , that inherits from it.
however i keep getting an error that says expected class name before { token
and it shows it where i wrote
class Savings : public account
{
there is obviously a class name there so why is it showing this error, its driving me crazy
anyone know what the problem is
here is the code:
account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
// No description
class Account
{
public:
// class constructor
Account(int, double);
// class destructor
~Account();
void operator+=(double);
void operator-=(double);
void setAccountNum(int);
int getAccountNum();
void setbalance(double);
double getbalance();
private:
int AccountNum;
double balance;
};
account.cpp
// Class automatically generated by Dev-C++ New Class wizard
#include "account.h" // class's header file
// class constructor
Account::Account(int accnum, double accbalance)
{
setAccountNum(accnum);
setbalance(accbalance);
}
void Account::setAccountNum(int num)
{
AccountNum = num;
}
int Account::getAccountNum()
{
return AccountNum;
}
void Account::setbalance(double sbalance)
{
balance = sbalance;
}
double Account::getbalance()
{
return balance;
}
void Account::operator+=(double num)
{
double accountbalance;
accountbalance = getbalance();
accountbalance += num;
setbalance(accountbalance);
}
void Account::operator-=(double num)
{
double accountbalance;
accountbalance = getbalance();
accountbalance -= num;
setbalance(accountbalance);
}
// class destructor
Account::~Account()
{
// insert your code here
}
savings.h
// Class automatically generated by Dev-C++ New Class wizard
#ifndef SAVINGS_H
#define SAVINGS_H
#include "account.h" // inheriting class's header file
// No description
class Savings : public account
{
public:
// class constructor
Savings();
// class destructor
~Savings();
};
#endif // SAVINGS_H
savings.cpp
// Class automatically generated by Dev-C++ New Class wizard
#include "savings.h" // class's header file
// class constructor
Savings::Savings()
{
// insert your code here
}
// class destructor
Savings::~Savings()
{
// insert your code here
}