高手指点一下哈 程序错误改不过来啊
来源:百度知道 编辑:UC知道 时间:2024/05/03 11:44:06
函数.h头文件
// SavingAccount.h
#ifndef SAVINGACCOUNT_H
#define SAVINGACCOUNT_H
class SavingAccount
{
public:
SavingAccount ( double , double );
static moodifyInterestRate(double);
void setSavingBalance (int);
const double getSavingBalance ();
double calculateMonthlyInterest();
~SavingAccount();
private:
static double annualInteresterRate;
double savingBalance;
};
#endif
函数的.cpp文件
//savingAccount.cpp
#include "SavingAccount.h"
#include <iostream>
using std::cout;
using std::endl;
SavingAccount::SavingAccount( double 1rate ,double save )
{
modifyInterest(rate);
savingBalance = 1save;
}
//静态成员函数
double SavingAccount::modifyInterest(double a )
{
annualInterest = a ;
}
void SavingAccount::setSavingBalance()
{
savingBalance= savingBalance*(1 +
// SavingAccount.h
#ifndef SAVINGACCOUNT_H
#define SAVINGACCOUNT_H
class SavingAccount
{
public:
SavingAccount ( double , double );
static moodifyInterestRate(double);
void setSavingBalance (int);
const double getSavingBalance ();
double calculateMonthlyInterest();
~SavingAccount();
private:
static double annualInteresterRate;
double savingBalance;
};
#endif
函数的.cpp文件
//savingAccount.cpp
#include "SavingAccount.h"
#include <iostream>
using std::cout;
using std::endl;
SavingAccount::SavingAccount( double 1rate ,double save )
{
modifyInterest(rate);
savingBalance = 1save;
}
//静态成员函数
double SavingAccount::modifyInterest(double a )
{
annualInterest = a ;
}
void SavingAccount::setSavingBalance()
{
savingBalance= savingBalance*(1 +
我把你的代码复制了下来,光从上面的代码来看,
错误:
1, 构造函数的参数为1rate和save,但使用的确实rate和lsave,应该改正
2,头文件里modifyInterestRate函数没有返回类型且写成了moodify
3,下面全是要么单词写错,要么忘了关键字之类的错误,把这些错误改正了再看。
double 1rate 多1
savingBalance = 1save; 多1
慢慢编,慢慢改。
savingBalance = 1save;应该把1去掉吧。
const double getSavingBalance (); 应该把const放在后面。
double calculateMonthlyInterest() 这个函数定义时应该返回一个double型的数,可返回的是一个int值,应该是double值。
语法有错误!检查下