9个错误,二个警告,vc2008里可能提示更多。。按Ctrl+F5,如果程序编译出错,你要仔细查看代码窗口下面的编译错误信息窗口,双击上面的错误条,自动弹到你的错误行,改错。
我们都在路上。。。。。
#include <iostream> #include <string> #include <cstdio> #define error 0 #define succee 1 using namespace std; class ACCOUNT { private: unsigned long ID; unsigned int password; string name; int ballance; public: ACCOUNT(unsigned long id,unsigned int pw,const char *n,int a); int cunkuan(unsigned long id,unsigned int pw,int a); int qukuan(unsigned long id,unsigned int pw,int a); int chaxun(unsigned long id,unsigned int pw); int check(unsigned long id,unsigned int pw); }; ACCOUNT::ACCOUNT(unsigned long id,unsigned int pw,const char * n,int a) { ID=id; password=pw; name = n; ballance=a; } int ACCOUNT::cunkuan(unsigned long id,unsigned int pw,int a) { if(check(pw,id)) return error; else { ballance+=a; return succee; cout<<"您的余额为:"<<ballance<<endl; } } int ACCOUNT::qukuan(unsigned long id,unsigned int pw,int a) { if(check(pw,id)) return error; else { if(ballance<a) cout<<"您的余额已不足!"<<endl; else ballance-=a; } return succee; } int ACCOUNT::chaxun(unsigned long id,unsigned int pw) { if(check(id,pw)) return ballance; else { cout << "here" << endl; return error; } } int ACCOUNT::check(unsigned long id,unsigned int pw) { if( id==ID && pw==password ) return succee; else return error; } int main() { ACCOUNT A(1005170228,123456,"Angel",500); int c; unsigned long id; unsigned int pw; int a; cout<<"欢迎使用"<<endl; cout<<"-----------------------"<<endl; cout<<"<1>存款\n<2>取款\n<3>查询余额\n<4>结束"<<endl; cout<<"请选择:"<<endl; cout << A.chaxun(1005170228, 123456) << endl; cin>>c; while(c!=4) { switch(c) { case 1: cout<<"请输入账号:"<<endl; cin>>id; cout<<"请输入密码:"<<endl; cin>>pw; cout<<"请输入存款余额:"<<endl; cin>>a; if(A.cunkuan(id,pw,a)) { cout<<"操作成功,您目前的余额为 "<<endl; cout<<A.chaxun(id,pw)<<"元"<<endl; } else cout<<"操作失败!"<<endl; getchar(); break; case 2: cout<<"请输入账号:"<<endl; cin>>id; cout<<"请输入密码:"<<endl; cin>>pw; cout<<"请选择取款余额:\t<1>100\t<2>200\t<3>500\t<4>1000"<<endl; cin>>a; if(A.qukuan(id,pw,a)) { cout<<"操作成功,您目前的余额为 "<<endl; cout<<A.chaxun(id,pw)<<"元"<<endl; } else cout<<"操作失败!"<<endl; getchar(); break; case 3: cout<<"请输入账号:"<<endl; cin>>id; cout<<"请输入密码:"<<endl; cin>>pw; cout << id << endl; cout << pw << endl; cout << "invoke here" << endl; if(A.check(id,pw)) cout<<"您目前的余额为 "<<endl; cout<<A.chaxun(id,pw)<<"元"<<endl; getchar(); break; } cout<<"请继续选择"<<endl; cout<<"<1>存款\n<2>取款\n<3>查询余额\n<4>结束"<<endl; cin >> c; } cout<<"谢谢使用!"<<endl; getchar(); return 0; }
#include<iostream> #include<string.h> using namespace std; //#define error 0 //#define succee 1 class ACCOUNT { private: unsigned long ID; unsigned int password; char name[20]; int ballance; public: ACCOUNT(unsigned long id,unsigned int pw,char *n,int a); int cunkuan(unsigned long id,unsigned int pw,int a); int qukuan(unsigned long id,unsigned int pw,int a); int chaxun(unsigned long id,unsigned int pw); int check(unsigned long id,unsigned int pw); }; ACCOUNT::ACCOUNT(unsigned long id,unsigned int pw,char *n,int a) { ID=id;password=pw; strcpy(name, n); ballance=a; } int ACCOUNT::cunkuan(unsigned long id,unsigned int pw,int a) { if(check(pw,id)) return 0; else { ballance+=a; return 1; cout<<"您的余额为:"<<ballance<<endl; } } int ACCOUNT::qukuan(unsigned long id,unsigned int pw,int a) { switch(a){ case 1:a=100; break; case 2:a=200; break; case 3:a=500; break; case 4:a=1000; } if(!check(id,pw)){ return 0; cout<<"用户名密码错误!!"<<endl; } else {if(ballance<a) cout<<"您的余额已不足!"<<endl; else ballance-=a; return ballance; } } int ACCOUNT::chaxun(unsigned long id,unsigned int pw) { int ji=check(id,pw); if(ji==1) return ballance; else return 0; } int ACCOUNT::check(unsigned long id,unsigned int pw) { if(id==1005170228&&pw==123456) return 1; else return 0; } void main() { ACCOUNT A(1005170228,123456,"Angel",500); int c; unsigned long id; unsigned int pw; int a; loop: cout<<"欢迎使用"<<endl; cout<<"-----------------------"<<endl; cout<<"<1>存款\n<2>取款\n<3>查询余额\n<4>结束"<<endl; cout<<"请选择:"<<endl; cin>>c; //getchar(); while(c!=4) { switch(c) { case 1: cout<<"请输入账号:"<<endl; cin>>id; cout<<"请输入密码:"<<endl; cin>>pw; cout<<"请输入存款余额:"<<endl; cin>>a; if(A.cunkuan(id,pw,a)) { cout<<"操作成功,您目前的余额为 "<<endl; int ui; ui=A.chaxun(id,pw); cout<<ui<<"元"<<endl; } else cout<<"操作失败!"<<endl; //getchar(); goto loop; case 2: cout<<"请输入账号:"<<endl; cin>>id; cout<<"请输入密码:"<<endl; cin>>pw; cout<<"请选择取款余额:\t<1>100\t<2>200\t<3>500\t<4>1000"<<endl; cin>>a; if(A.qukuan(id,pw,a)) { cout<<"操作成功,您目前的余额为 "<<endl; cout<<A.chaxun(id,pw)<<"元"<<endl; } else cout<<"操作失败!"<<endl; //getchar(); goto loop; case 3: cout<<"请输入账号:"<<endl; cin>>id; cout<<"请输入密码:"<<endl; cin>>pw; if(A.check(id,pw)) cout<<"您目前的余额为 "<<endl; cout<<A.chaxun(id,pw)<<"元"<<endl; //getchar(); goto loop; } cout<<"请继续选择"<<endl; cout<<"<1>存款\n<2>取款\n<3>查询余额\n<4>结束"<<endl; } cout<<"谢谢使用!"<<endl; //getchar(); }稍微修改了下,不过有些当密码用户名错误时的提示有些没弄,