| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3857 人关注过本帖
标题:多文件编程程序编译错误求解
只看楼主 加入收藏
qq923012373
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2016-7-24
收藏
 问题点数:0 回复次数:1 
多文件编程程序编译错误求解
程序代码:
#ifndef __ACCOUNT_H__
#define __ACCOUNT_H__
class SavingAccount{
private:
    int id;
    int lastDate;
    double balance;
    double rate;
    double accumlation;
    static double total;
    void  record(int date,double amount);
    double accumlate(int date)const{
        return accumlation+balance*(date-lastDate);
    }
public:
    SavingAccount(int id,int date,double rate);
    int getId()const{return id;}
    double getRate()const{return rate;}
    double getBalance()const{return balance;}
    static double getTotal(){return total;}
    void deposit(int date,double amount);
    void withdraw(int date,double amount);
    void settle(int date);
    void show()const;
};
#endif

程序代码:
#include"account.h"
#include<iostream>
#include<cmath>
using namespace std;

double SavingAccount::total=0;
SavingAccount::SavingAccount(int id,int date,double rate)

 : id(id),balance(0),lastDate(date),rate(rate),accumlation(0){
    cout<<date<<" #"<<id<<" id created!"<<endl;
}
SavingAccount::record(int date,double amount){
    accumlation=accumlate(date);
    lastDate=date;
    amount=floor(amount*100+0.5)/100;
    balance+=amount;
    total+=amount;
    cout<<date<<"\t#"<<id<<amount<<"\t"<<balance<<endl;
}
SavingAccount::deposit(int date,double amount){
    record(date,amount);
}
SavingAccount::withdraw(int date,double amount){
    if(amount<=balance)
    record(date,-amount);
    else
        cout<<"Error:not enough money!"<<endl;
}
SavingAccount::settle(int date){
    double interest=accunlate(date)*rate/365;
    if(interest!=0)
        record(date,interest);
    accumlation=0;
}
void SavingAccount::show(){
    cout<<"#"<<id<<"\tBalance:"<<balance;
}

程序代码:
#include"account.h"
#include<iostream>
using namespace std;

ing main(){
    SavingAccount sao(20160727,1,0.015);
    SavingAccount sal(20160728,1,0.015);
    sa0.deposit(5,5000);
    sal.deposit(25,10000);
    sao.deposit(45,5500);
    sal.withdraw(60,4000);
    sao.settle(90);
    sal.settle(90);
    sao.show(); cout<<endl;
    sal.show(); cout<<endl;
    cout<<"Total:"<<SavingAccount.getTotal()<<endl;
    return 0;
}

错误:
--------------------Configuration: 511 - Win32 Debug--------------------
Compiling...
account.cpp
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(11) : error C2556: 'int __thiscall SavingAccount::record(int,double)' : overloaded function differs only by return type from 'void __thiscall SavingAccount::record(int,double)
'
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(11) : see declaration of 'record'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(11) : error C2371: 'record' : redefinition; different basic types
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(11) : see declaration of 'record'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(19) : error C2556: 'int __thiscall SavingAccount::deposit(int,double)' : overloaded function differs only by return type from 'void __thiscall SavingAccount::deposit(int,doubl
e)'
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(21) : see declaration of 'deposit'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(19) : error C2371: 'deposit' : redefinition; different basic types
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(21) : see declaration of 'deposit'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(20) : error C2264: 'record' : error in function definition or declaration; function not called
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(22) : error C2556: 'int __thiscall SavingAccount::withdraw(int,double)' : overloaded function differs only by return type from 'void __thiscall SavingAccount::withdraw(int,dou
ble)'
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(22) : see declaration of 'withdraw'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(22) : error C2371: 'withdraw' : redefinition; different basic types
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(22) : see declaration of 'withdraw'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(24) : error C2264: 'record' : error in function definition or declaration; function not called
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(28) : error C2556: 'int __thiscall SavingAccount::settle(int)' : overloaded function differs only by return type from 'void __thiscall SavingAccount::settle(int)'
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(23) : see declaration of 'settle'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(28) : error C2371: 'settle' : redefinition; different basic types
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(23) : see declaration of 'settle'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(29) : error C2065: 'accunlate' : undeclared identifier
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(31) : error C2264: 'record' : error in function definition or declaration; function not called
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\account.cpp(34) : error C2511: 'show' : overloaded member function 'void (void)' not found in 'SavingAccount'
        c:\program files (x86)\microsoft visual studio\myprojects\511\account.h(3) : see declaration of 'SavingAccount'
main.cpp
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\main.cpp(5) : error C2146: syntax error : missing ';' before identifier 'main'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\main.cpp(5) : error C2501: 'ing' : missing storage-class or type specifiers
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\511\main.cpp(5) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

511.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: balance 编程程序 record 
2016-07-27 17:21
rjsp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:528
帖 子:9031
专家分:54061
注 册:2011-1-18
收藏
得分:0 
自己看错误信息呀,写得清清楚楚,比如第一条
 'int __thiscall SavingAccount::record(int,double)' : overloaded function differs only by return type from 'void __thiscall SavingAccount::record(int,double)
2016-08-19 16:18
快速回复:多文件编程程序编译错误求解
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033320 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved