#pragma once

class Account
{
public:
	//default constructors
	Account();
	//constructor
	Account(double newSavingsBalance);		
	//Methods
	
	//double MonthlyInterestRate();
	//double newBalance();
	void getMonthlyInterestRate();
	static double AnnualInterestRate();
	static void ModifyInterestRate(double newAnnualInterestRate);
	void setSavingsBalance(double newSavingsBalance);
	double getSavingsBalance();
	double getAnnualInterestRate();

public:
	~Account(void);

private:
	double SavingsBalance;
	//static double AnnualInterestRate;	
};
#include "StdAfx.h"
#include "Account.h"

Account::Account(void)
{
	
}
Account::Account(double newSavingsBalance)
{
	setSavingsBalance(newSavingsBalance);
}
Account::~Account(void)
{
}

void Account::getMonthlyInterestRate()
{
	setSavingsBalance(getSavingsBalance() + (getSavingsBalance() * (AnnualInterestRate / 12)));
}
//gets the current balance in account
double Account::getSavingsBalance()
{
      return SavingsBalance; 
}

void Account::setSavingsBalance(double newSavingsBalance)
{
	SavingsBalance = newSavingsBalance;
}
void Account::ModifyInterestRate(double newAnnualInterestRate)
{
	AnnualInterestRate = newAnnualInterestRate;
}
// SavingsAccount.cpp : main project file.

#include "stdafx.h"
#include "Account.h"
#include <iostream>
using namespace System;
using namespace std;


int main(array<System::String ^> ^args)
{
	Account Eddie(2000.00);
	Account Amy(3000.00);

	Eddie.ModifyInterestRate(0.03);
	Eddie.getMonthlyInterestRate();
	Amy.getMonthlyInterestRate();

	cout<<Eddie.getSavingsBalance()<<endl;



	
	return 0;
}

Before I commented out the private: static double AnnualInterestRate I was getting a link error - unresolved token private static double Account::AnnualInterestRate

so I made it public and I got the same error.

>>//static double AnnualInterestRate
static class variables are just like global variables with a class scope. They have to be declared at the top of a *.cpp file just as if they were normal global variables.

// account.cpp file
#include "StdAfx.h"
#include "Account.h"

double Account::AnnualInterestRate = 0;
// rest of code goes here

Seriously Wow!!!, thank you so much. From all my reading and all my classes I never got that.

:)

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.