Image

Imagesnapdragon2003 wrote in Imagecpp

You guys wouldn't kill me if I asked one last question, would you? :-) This one is probably an easy one. I'm getting "error C2724: 'SavingsAccount::modifyInterestRate' : 'static' should not be used on member functions defined at file scope".

I understand that I have to treat static functions a bit differently, but I'm not quite clear on how to do this properly. (My previous four classes all had me program in Java, so I'm still adjusting to the differences.) Could someone *possibly* explain how to go about this?

class SavingsAccount
{
   private:
      static float annualInterestRate;
      float balance;
   public:
      SavingsAccount(float amountToDeposit)
      { balance = amountToDeposit; }
      static void modifyInterestRate(float newRate);
      //   { annualInterestRate = newRate; }
      void calculateMonthlyInterest()
         { balance += (balance * (annualInterestRate / 12)); }
      float getBalance()
         { return balance; }
};

static void SavingsAccount::modifyInterestRate(float newRate)
{
   annualInterestRate = newRate;
}


And then once this is finished, I can finally go home... :-D