I am trying to do a simple hw problem involving namespace, static data members and functions. I am getting an unresolved external symbol error
Error 1 erro
you need a line in your cpp file
double JWong::SavingsAccount::annualInterestRate = 0.7; // or whatever you like
I'm presuming you are actually compiling the .cpp file (because the other functions link).
The error is likely due to not defining the annualInterestRate
static variable.
You have declared it (in the class header), but it's not defined. In your cpp file add:
// static member definition
double JWang::SavingsAccount::annualInterestRate = ...;
See an article highlighting the difference between declaration and definition of static members.
Section 9.4.2 of the C++ Standard says "The definition for a static data member shall appear in a namespace scope enclosing the member’s class definition."