Account.h 文件
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account
{
private:
//attributes
double balance;
public:
//methods
void set_balance(double bal);
double get_balance();
};
#endif
Account.cpp 文件
#include "Account.h"
void Account::set_balance(double bal){
balance=bal;
}
double Account::get_balance(){
return balance;
}
main.cpp 文件
#include<iostream>
#include"Account.h"
int main(){
Account frank_account;
frank_account.set_balance(200.00);
double showBalance=frank_account.get_balance();
return 0;
}
错误
C:\Users\Dell\AppData\Local\Temp\ccZOi0ua.o: In function `main':
F:/OPP/opp10/main.cpp:6: undefined reference to `Account::set_balance(double)'
F:/OPP/opp10/main.cpp:7: undefined reference to `Account::get_balance()'
collect2.exe: error: ld returned 1 exit status
Build finished with error(s).
The terminal process terminated with exit code: -1.
请解释错误信息并提供解决方案。谢谢你................................................ ..................................................... .....................