求购铁锹生产线:哪个C++高手帮我看一下程序,我不知道哪里出错了~!

来源:百度文库 编辑:高考问答 时间:2024/04/29 20:55:04
我自己编的一道注册程序.但是还没编完.不知道为什么出错,但编译时说主程序中的语句错误,请大虾们帮个忙看一下.小弟万分感谢`!
//2.cpp 为主程序
#include<iostream.h>
void main()
{
name bb;
bb.inname();
}

//1.h 为头文件
class name
{
public:
int inname();
void pawr();
void denglu();
char name1[8],password[12],pw[12];
private:
int i,j,k;
};

//1.cpp 为程序
#include<iostream.h>
#include<conio.h>
#include"1.h"
int name::inname();
{
// name aa;
cout<<"用户名只能为1-8位 请输入用户名:";
for(i=0;i<8;i++)
name1[i]=getch();
cout<<endl;
for(j=0;j<=3;j++)
{
if(j==3)
{
cout<<"输出入三次密码都不想同请重新注册~!"<<endl;
return 0;
break;
}
// aa.pawr();
pawr();
for(i=0;i<12;i++)
if(passwore[i]!=pw[i])
cout<<"您输入的两次密码不相同请重新输入~!"<<endl;
else
{
cout<<"注册成功~!"<<endl;
cout<<"您的注册信息如下:"<<endl;
cout<<"用户名:";
for(i=0;i<8;i++)
cout<<name1[i];
for(i=0;i<12;i++)
cout<<pw[i];
return 1;
break;
}
}
}

void name::pawr()
{
cout<<"密码只能为1-12位 请输入密码:";
for(i=0;i<12;i++)
password[i]=getch();
cout<<endl;
cout<<"请在输入一次用户密码:";
for(i=0;i<12;i++)
pw[i]=getch();
cout<<endl;
}
那也不对呀
提示的错误::\111111111\zhangshuai\zhangshuai\1.cpp(37) : warning C4715: 'name::inname' : not all control paths return a value
D:\111111111\zhangshuai\zhangshuai\2.cpp(4) : error C2065: 'name' : undeclared identifier
D:\111111111\zhangshuai\zhangshuai\2.cpp(4) : error C2146: syntax error : missing ';' before identifier 'bb'
D:\111111111\zhangshuai\zhangshuai\2.cpp(4) : error C2065: 'bb' : undeclared identifier
D:\111111111\zhangshuai\zhangshuai\2.cpp(5) : error C2228: left of '.inname' must have class/struct/union type

你说有内存的溢出,在哪里呀

1.cpp中int name::inname();后面不需要分号
拼写错误:password

另外对你的 1.cpp修改为一下的代码以后可以运行通过,
功能可以实现:
#include<iostream.h>
#include<conio.h>
#include"1.h"
int name::inname()
{
// name aa;
cout<<"user name should be 1-8bit,input "<<endl;

for(i=0;i<8;i++) {
name1[i]=getche();
}
cout<<endl;

pawr();
for(i=0;i<12;i++)
if(password[i]!=pw[i]) {
cout<<"the password is not the same please register again!!"<<endl;
return 0;}
else
{
cout<<"注册成功~!"<<endl;
cout<<"注册信息如下:"<<endl;
cout<<"user name:";
for(i=0;i<8;i++)
cout<<name1[i];
cout<<"password :";
for(i=0;i<12;i++)
cout<<pw[i];
return 1;
break;
}
}

void name::pawr()
{
//cout<<"password should be 1-12bit,please input:";
cprintf("password should be 1-12bit,please input:");
for(i=0;i<12;i++) {
password[i]=getch();
cprintf("*");
}
cout<<endl;
cprintf("please input password again:");
for(i=0;i<12;i++){
pw[i]=getch();
cprintf("*");
}

}

......
int name::inname(); 加了;
if(passwore[i]!=pw[i]) .h文件里定义的是password

而且还有内存溢出