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
}

Try capital 'A' instead of lowercased 'a', in class Savings : public Account{...}

I tried that bu then i get errors saying
no matching function to call Account::Account
note: candidates are Account::Account(const Account&)
note: Account::Account(int, double)

You have not provided the default constructor Account::Account(), and it seems something wants it.

just curious, did you copy all the code for your account header?

It appears to be missing #endif which would explain why it can't find the constructor

the #endif is there, it must have been cut off when i copied it

Did you try the suggestion given by @Moschops

My teacher showed me the correction
had to make Savings(int, double) to match Account
thank you all for responding

bkoper16: Please mark this thread as solved. Only you, the original poster (OP) have that link. Marking threads solved, when they are solved of course, helps keep DaniWeb working smoothly.

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.