codeblocks多文件项目如何执行

codeblocks多文件如何执行呢,
书本上抄的.h头文件代码,.cpp类文件代码,.cpp源文件代码都有了,放在了一个文件夹了,下一步要怎么做呢
参考了网上的调出左侧项目栏的答案,但是没解决
单个程序运行时报错:
C++多文件,类实现文件account.cpp报错undefined reference to "WinMain@16"
主函数文件5_11.cpp报错undefined reference to SavingsAccount::SavingsAccount(int, int, double)
应该不是单个文件的问题,多文件到底怎么运行呢

img

img


account.h


#ifndef ACCOUNT_H__
#define ACCOUNT_H__
class SavingsAccount { //储蓄账户类
private:
    int id;
    double balance;
    double rate;
    int lastDate;
    double accumulation;
    static double total;
    //记录一笔账,date日期,amount为金额,desc为说明
    void record(int date, double amount);
    //获得到指定日期为止的存款金额按日累计值
    double accumulate(int date) const {
        return accumulation+balance*(date-lastDate);
    }
public:
    //构造函数
    SavingsAccount(int date, int id, double rate);
    int getId() const{return id;}
    double getBalance() const{return balance;}
    static double getTotal() {return total;}
    void deposit(int date, double amount);  //存入现金
    void withdraw(int date, double amount); //取出现金
    //结算利息,每年1月1日调用一次该函数
    void settle(int date);
    //显示账户信息
    void show() const;
};
#endif // ACCOUNT_H_INCLUDED

account.cpp


#include "account.h"
#include
#include
using namespace std;

double SavingsAccount::total=0;
//SavingsAccount类相关成员函数的实现
SavingsAccount::SavingsAccount(int date,int id, double rate)
    :id(id), balance(0), rate(rate), lastDate(date), accumulation(0) {
    cout<<date<<"\t#"<void SavingsAccount::record(int date, double amount) {
    accumulation=accumulate(date);
    lastDate=date;
    amount=floor(amount*100+0.5)/100;
    balance+=amount;
    total+=amount;
    cout<<date<<"\t#"<void SavingsAccount::deposit(int date, double amount) {
    record(date, amount);
}
void SavingsAccount::withdraw(int date, double amount) {
    if(amount > getBalance())
        cout<<"Error: not enough money"<else
        record(date, -amount);
}
void SavingsAccount::settle(int date) {
    double interest=accumulate(date) * rate / 365; //计算年息
    if(interest != 0)
        record(date, interest);
    accumulation = 0;
}
void SavingsAccount::show() const {
    cout<<"# "<

5_11.cpp

#include "account.h"
#include
using namespace std;
int main()
{
    //建立几个账户
    SavingsAccount sa0(1, 21325320, 0.015);
    SavingsAccount sa1(1, 58320212, 0.015);
    //几笔账目
    sa0.deposit(5, 5000);
    sa1.deposit(25, 10000);
    sa0.deposit(45, 5500);
    sa1.deposit(60, 4000);
    //开户后第90天到了银行计息日,结算所有账户的年息
    sa0.settle(90);
    sa1.settle(90);
    //输出各账户信息
    sa0.show();   cout<show();   cout<"Total: "<getTotal()<return 0;
}


参考这个

关键在于,需要手工添加文件,网上流传的一个include cpp的做法,其实不算多文件
多文件的意思是分辨编译成obj,再链接