Static data members should be declared inside class body but defined outside of class (constant static member is an exemption).
class Account {
public:
// interface functions here
void applyint() { amount += amount * interestRate; }
static double rate() { return interestRate; }
static void rate(double); // sets a new rate
private:
std::string owner;
double amount;
static double interestRate;
static double initRate();
};
Define static data members: don't use static keyword.
Outside of class body.
double Account::interestRate = initRate();
Define static member function: don't use static keyword.
void Account::rate(double newRate)
{
interestRate = newRate;
}