Function 调用静态函数时出现未解决的外部错误
这简直让我发疯。我已经尝试了在其他帖子上找到的所有东西,但没有任何效果。。。这不应该这么复杂Function 调用静态函数时出现未解决的外部错误,function,static,externals,Function,Static,Externals,这简直让我发疯。我已经尝试了在其他帖子上找到的所有东西,但没有任何效果。。。这不应该这么复杂 #include <iostream> #include <iomanip> using namespace std; class SavingsAccount { private: float savingsBalance; static float annualInterestRate; public: static void modif
#include <iostream>
#include <iomanip>
using namespace std;
class SavingsAccount
{
private:
float savingsBalance;
static float annualInterestRate;
public:
static void modifyInterestRate(float interestRate)
{
annualInterestRate = interestRate;
}
};
int main()
{
SavingsAccount::modifyInterestRate(.03);
cout << endl;
system("pause");
return 0;
}
#包括
#包括
使用名称空间std;
阶级储蓄帐户
{
私人:
浮动储蓄平衡;
静态浮动年利率;
公众:
静态空隙改性酯(浮动酯)
{
年利率=利率;
}
};
int main()
{
SavingsAccount::modifyInterestRate(.03);
你不能在类中声明annualInterestate
,但实际上你没有在任何地方定义它。我尝试在modifyInterestate函数中定义它,但我得到了一个范围错误。在你的类和int main()之间添加float SavingsAccount::annualInterestate;Omg,你是个救命恩人。谢谢!