|
![]() | 作者: peachboy [peachboy]
![]() |
登录 |
本帖由 [日月双星] 从 << 菜鸟乐园>> 转移而来#include<iostream.h> class user { protected: char*user_name; int user_password; public: void set_member(char*name,int password) { user_name=name; user_password=password; } void show_user(void) { cout<<"请输入你的姓名\n"; cin>>user_name; if(user_name!=name) cout<<"查无此用户\n"; else cout<<"请输入密码\n"; cin>>user_password; if(user_password!=password) cout<<"你的密码不正确,请你重新输入\n"; } }; void main(void) { char*name,int password; cout<<"请输入你的姓名\n"; cin>>name; int i; for(i=1;i<=3;i++) cout<<"你输入的次数过多,请查清后再取\n"; user o; o.set_member(n="taoshucheng",p=851018); o.show_user; } 以上是我编的程序,可是就是运行不起来,帮忙,看看 |
地主 发表时间: 04-08-10 19:59 |
![]() | 回复: ProgramLive [coolcall] ![]() |
登录 |
有很多的地方有问题 #include<iostream.h> class user { protected: char username[20]; int userpassword; public: int set_member(char name[],int password); }; int user::set_member(char name[],int password) { int p=0; cout<<"请输入你的姓名\n"; cin>>username; int w=strcmp(username,name); if(w!=0) cout<<"查无此用户\n"; else cout<<"请输入密码\n"; cin>>userpassword; if(userpassword != password) {cout<<"你的密码不正确,请你重新输入\n";p=1;} return p; } void main(void) { int c=0; user o; for(int y=0;y<3;y++){ int j=o.set_member("taoshucheng",851018); if(j==0){break;} } } |
B1层 发表时间: 04-08-11 11:35 |
![]() | 回复: Garu [syshunter] ![]() |
登录 |
class user { protected: char user_name[20]; int user_password; public: void set_member(char*name,int password) { strcpy(user_name,name); user_name[strlen(user_name)]='\0'; user_password=password; } void show_user(void) { char name[20]; int password; cout<<"请输入你的姓名\n"; cin>>name; if(strcmp(user_name,name)) cout<<"查无此用户\n"; else { cout<<"请输入密码\n"; cin>>password; if(user_password!=password) cout<<"你的密码不正确,请你重新输入\n"; } }; 。。。。改不下去了。。建议楼主把数组与指针那章反复的看反复的练习。另外在写程序之前先把思路整理好。 |
B2层 发表时间: 04-08-11 13:17 |
![]() | 回复: Garu [syshunter] ![]() |
登录 |
我也糊涂了,show_user少了个}![]() |
B3层 发表时间: 04-08-11 13:18 |
![]() | 回复: TomyChen [quest] ![]() |
登录 |
类: CUser 代码: [此贴被 TomyChen(quest) 在 08月11日16时14分 编辑过] |
B4层 发表时间: 04-08-11 16:14 |
![]() | 回复: Garu [syshunter] ![]() |
登录 |
恭贺我们CUser v1.0发布![]() ![]() 还是那句话说的对呀,专业程序员没有耐心和细心是不行嘀 |
B5层 发表时间: 04-08-11 18:58 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号