| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 678 人关注过本帖
标题:在线等 菜鸟问题
取消只看楼主 加入收藏
忘记喧嚣
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-10-7
收藏
 问题点数:0 回复次数:1 
在线等 菜鸟问题
这个是错误
--------------------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;

}

谢谢帮小弟看看哈.
我用的是英文版的 VC++6.0
搜索更多相关主题的帖子: 在线 
2007-11-28 22:16
忘记喧嚣
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-10-7
收藏
得分:0 
谢谢你哈
2007-11-28 22:24
快速回复:在线等 菜鸟问题
数据加载中...
 
   



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

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