菜鸟问题
这个是错误--------------------Configuration: fig_account - Win32 Debug-------------------- Compiling... fig_account.cpp Linking... fig_account.obj : error LNK2001: unresolved external symbol "public: int __thiscall Account::debit(void)" ([email=?debit@Account@@QAEHXZ]?debit@Account@@QAEHXZ[/email])
fig_account.obj : error LNK2001: unresolved external symbol "public: int __thiscall Account::crddit(void)" ([email=?crddit@Account@@QAEHXZ]?crddit@Account@@QAEHXZ[/email])
fig_account.obj : error LNK2001: unresolved external symbol "public: __thiscall Account::Account(int)" (??0Account@@QAE@H@Z) Debug/
fig_account.exe : fatal error LNK1120: 3 unresolved externals Error executing link.exe. fig_account.exe - 4 error(s), 0 warning(s)
编一个程序实现存款和取款 然后写两次测试对象
-----------------------------------------
//Account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account
{
public:
Account(int);
int crddit( );
int debit();
void setBalance(int);
int getBalance();
private:
int blance;
};
#endif
--------------------------------------------------------------
//Account.cpp
#include<iostream>
using namespace std;
#include "Account.h"
Account::Account(int i)
{
if(i>=0)
setBalance(i);
else
{
setBalance(0);
cout<<"invalid number";
}
}
int Account::crddit()
{
int add=0;
cout<<"input you want to add to number:";
cin>>add;
blance+=add;
cout<<"the blance after add:"<<getBalance()<<endl;
}
int Account::debit()
{
int dicre=0;
cout<<"input you want to dicre number:";
cin>>dicre;
if (dicre<=blance)
{
blance-=dicre;
cout<<"the blance after dicre:";
}
else
cout<<"Debit amount exceeded account blance"<<getBalance()<<endl;
}
void Account::setBalance(i)
{
blance=i;
}
int Account::getBalance()
{
return balance;
}
--------------------------------------------------------------------
//fig_account.cpp
#include<iostream>
using namespace std;
#include"Account.h"
int main()
{
Account account1(50);
Account account2(-50);
account1.crddit();
account1.debit();
account2.crddit();
account2.debit();
return 0;
}
谢谢帮小弟看看哈.