程序帮助 [英] Program Help

查看:67
本文介绍了程序帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是学生学习C ++而我的教授并没有多大帮助,她的观点是

如果你不明白我无法帮助你....... br />

我们应该做一个基本程序作为登录系统。我得到了b $ b可以得到一些我无法理解的错误。


任何帮助都将不胜感激。

使用:MS Visual Studio .Net 2003

语言:C ++

项目中心:课程

**代码**

/ *

姓名:Matthew Gonzalez

Prog姓名:gonzalez_PA10

日期:4/27/05

目的:课程

* /


#include< iostream>

using namespace std;


//班级

班级用户

{

私人:


int userId;

char firstName [20];

char lastName [20];

char password [20];

public:


void setUserData(char firstName [20],char lastName [20],char password [20]);

void changePassword(char password [20],char newPass [20]);

void displayUser(int userId,char firstName [20],char lastName [20],char

密码[20]);

};

//结束类

User :: setUserData(char firstName [20],char lastName [20],char password [20])

{

cout<<""请输入您的名字:"<< endl;

cin>> firstName [20];

cout<<"请输入您的姓氏:"<< endl;

cin>> lastName [20];

cout<<"请输入您的密码:"<< endl;

cin>>密码[20];

//结束setuserdatafunction

}

User :: changePassword(char password [20],char newPass [20])

{

cout< ;<"请输入新密码"<< endl;

cin>> newPass [20];


if(密码[20] ] == newPass [20])

{

cout<<"你的密码是一样的。不会发生任何变化。<< endl;

}

其他

{

if(密码[20]!= newPass [20])


newPass [20] =密码[20];

}

}

User :: displayUser(int userId,char firstName [20],char lastName [20],char

password [20])

{

cout<<"用户ID为:"<< userId<< endl;

cout<<" The First name is:"<<< firstName [20]<< endl;

cout<<"姓氏是:"<<< lastName [20]<< ; endl;

cout<<"密码为:<<< password [20]<< endl;

//结束显示用户功能

}


int main()

{

//用户对象
用户登录;

int userId;

char firstName [20];

char lastName [20];

char密码[20];

char newPass [20];

char answer;


cout< <" ;请输入用户ID:"<< endl;

cin>> userId;

logon.setUserData(char firstName [20],char lastName [ 20],char密码[20]);

cout<<"你想更改密码吗?输入Y或N:<< endl;

cin>> answer;

//如果

if(answer = =''y'')

{

logon.changePassword(char password [20],char newPass [20]);

logon .displayUser(int UserId,char firstName [20],char lastName [20],char

password [20]);

}

否则


if(answer ==''n'')

{

logon.displayUser(int UserId,char firstName [20],char lastName [20],char

密码[20]);

}

// endif


返回0;

}


**结束代码**

Hi, I''m a student learning C++ and my professor isn''t much help, her view is
if you dont get it I ain''t helping you....

We are supposed to do a basic program as a logon system. I got as far as I
could and came up with some errors I could not understand.

Any Help would be appreciated.
Using: MS Visual Studio .Net 2003
Language: C++
Program centers around: Classes
**CODE**
/*
Name: Matthew Gonzalez
Prog Name: gonzalez_PA10
Date: 4/27/05
Purpose: Classes
*/

#include <iostream>
using namespace std;

//class
class User
{
private:

int userId;
char firstName[20];
char lastName[20];
char password[20];
public:

void setUserData(char firstName[20],char lastName[20],char password[20]);
void changePassword (char password[20],char newPass[20]);
void displayUser(int userId,char firstName[20],char lastName[20], char
password[20]);
};
//end class
User::setUserData(char firstName[20],char lastName[20],char password[20])
{
cout<<"Please Enter Your First Name: "<<endl;
cin>>firstName[20];
cout<<"Please Enter your Last Name: "<<endl;
cin>>lastName[20];
cout<<"Please Enter your Password: "<<endl;
cin>>password[20];
//end setuserdatafunction
}
User::changePassword(char password[20],char newPass[20])
{
cout<<"Please enter new password"<<endl;
cin>>newPass[20];

if(password[20]==newPass[20])
{
cout<<"Your password is the same. No Change will occur."<<endl;
}
else
{
if(password[20]!=newPass[20])

newPass[20]=password[20];
}
}
User::displayUser(int userId,char firstName[20],char lastName[20], char
password[20])
{
cout<<"The User id is: "<<userId<<endl;
cout<<"The First name is: "<<firstName[20]<<endl;
cout<<"The Last name is: "<<lastName[20]<<endl;
cout<<"The password is: "<<password[20]<<endl;
//end display user function
}

int main()
{
//user object
User logon;
int userId;
char firstName[20];
char lastName[20];
char password[20];
char newPass[20];
char answer;

cout<<"Please enter a user Id: "<<endl;
cin>>userId;
logon.setUserData(char firstName[20],char lastName[20],char password[20]);
cout<<"Do you want to change your password? Enter Y or N: "<<endl;
cin>>answer;
//if
if(answer==''y'')
{
logon.changePassword(char password[20],char newPass[20]);
logon.displayUser(int UserId,char firstName[20],char lastName[20],char
password[20]);
}
else

if(answer==''n'')
{
logon.displayUser(int UserId,char firstName[20],char lastName[20],char
password[20]);
}
//endif

return 0;
}

**END CODE**

推荐答案

gonzal51写道:
gonzal51 wrote:
我是学生学习C ++而我的教授没什么帮助,她的观点是<如果你没有得到它我无法帮助你....

我们应该做一个基本程序作为登录系统。我到目前为止可以得到一些我无法理解的错误。

任何帮助都会受到赞赏。

使用:MS Visual Studio。 Net 2003
语言:C ++
课程中心:课程

**代码**
/ *
姓名:Matthew Gonzalez
Prog姓名:gonzalez_PA10
日期:4/27/05
目的:课程
* /

#include< iostream>
使用命名空间std; <
//类
类用户
{
私有:

int userId;
char firstName [20];
char lastName [20];
char password [20];



使用std :: string而不是char数组会更好。


public:

void setUserData(char firstName [20],char lastName [20],char password [20]);
void changePassword(char password [20],char newPass [20]);
void displayUser( int userId,char firstName [20],char lastName [20],char
password [20]);
};
// end class


void User :: setUserData(char firstName [20],char lastName [20],char password [20])

{
cout<<"请输入你的名字:"<< endl;
cin>> firstName [20];
cout<<"请输入您的姓氏:"<< endl;
cin>> lastName [20];
cout<<"请输入您的密码:"<< endl;
cin>>密码[20];
/ / end setuserdatafunction
}


void User :: changePassword(char password [20],char newPass [20])

{
cout<<"请输入新密码&q uot;<< endl;
cin>> newPass [20];

if(password [20] == newPass [20])
{
cout<<"您的密码是相同的。不会发生变化。<< endl;
}

{
if(password [20]!= newPass [20])

newPass [20] =密码[20];
}
}


void User :: displayUser(int userId,char firstName [20], char lastName [20],char

密码[20])
{
cout<<"用户ID是:"<< userId<< endl;
cout<<"""""""""<<<" firstName [20]<< endl;
cout<<"""""""" << lastName [20]<< endl;
cout<<"密码为:"<< password [20]<< endl;
//结束显示用户功能

int main()
//用户对象
用户登录;
int userId;
char firstName [20];
char lastName [20];
char password [20];
char newPass [20];
char answer;

cout<<"请输入用户ID:"<< endl;
cin>> userId;


logon.setUserData(firstName,lastName,password);

cout<<"您要更改密码吗?输入Y或N:"<< endl;
cin>> answer;
// if
if(answer ==''y'')
{


logon.changePassword(password,newPass);

logon.displayUser(userId,firstName,lastName,password);


}


if(answer ==''n'')
{


logon.displayUser( userId,firstName,lastName,password);

}
// endif

返回0;
}
Hi, I''m a student learning C++ and my professor isn''t much help, her view is
if you dont get it I ain''t helping you....

We are supposed to do a basic program as a logon system. I got as far as I
could and came up with some errors I could not understand.

Any Help would be appreciated.
Using: MS Visual Studio .Net 2003
Language: C++
Program centers around: Classes
**CODE**
/*
Name: Matthew Gonzalez
Prog Name: gonzalez_PA10
Date: 4/27/05
Purpose: Classes
*/

#include <iostream>
using namespace std;

//class
class User
{
private:

int userId;
char firstName[20];
char lastName[20];
char password[20];

Using std::string instead of char arrays would be better.

public:

void setUserData(char firstName[20],char lastName[20],char password[20]);
void changePassword (char password[20],char newPass[20]);
void displayUser(int userId,char firstName[20],char lastName[20], char
password[20]);
};
//end class
void User::setUserData(char firstName[20],char lastName[20],char password[20])
{
cout<<"Please Enter Your First Name: "<<endl;
cin>>firstName[20];
cout<<"Please Enter your Last Name: "<<endl;
cin>>lastName[20];
cout<<"Please Enter your Password: "<<endl;
cin>>password[20];
//end setuserdatafunction
}
void User::changePassword(char password[20],char newPass[20])
{
cout<<"Please enter new password"<<endl;
cin>>newPass[20];

if(password[20]==newPass[20])
{
cout<<"Your password is the same. No Change will occur."<<endl;
}
else
{
if(password[20]!=newPass[20])

newPass[20]=password[20];
}
}
void User::displayUser(int userId,char firstName[20],char lastName[20], char
password[20])
{
cout<<"The User id is: "<<userId<<endl;
cout<<"The First name is: "<<firstName[20]<<endl;
cout<<"The Last name is: "<<lastName[20]<<endl;
cout<<"The password is: "<<password[20]<<endl;
//end display user function
}

int main()
{
//user object
User logon;
int userId;
char firstName[20];
char lastName[20];
char password[20];
char newPass[20];
char answer;

cout<<"Please enter a user Id: "<<endl;
cin>>userId;
logon.setUserData(firstName, lastName, password);
cout<<"Do you want to change your password? Enter Y or N: "<<endl;
cin>>answer;
//if
if(answer==''y'')
{
logon.changePassword(password, newPass);
logon.displayUser(userId, firstName, lastName, password);

}
else

if(answer==''n'')
{
logon.displayUser(userId, firstName, lastName, password);
}
//endif

return 0;
}



修复它以进行编译。我没有检查甚至没有运行代码。


Just fixed it to compile. I did not check or even run the code.


我想知道,(当我处理它时)我遇到了什么问题?

Ioannis Vranos < iv*@remove.this.grad.com>在消息中写道

新闻:Ov ************** @ TK2MSFTNGP10.phx.gbl ...
I was wondering, (while I work on it) what were the problems I was having?
"Ioannis Vranos" <iv*@remove.this.grad.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
gonzal51写道:
gonzal51 wrote:
我是学生学习C ++而我的教授并没有多大帮助,她的b $ b视图就是如果你不明白我无法帮助你... ..

我们应该做一个基本程序作为登录系统。我得到了
我可以得到一些我无法理解的错误。

任何帮助都将不胜感激。

使用:MS Visual Studio。 Net 2003
语言:C ++
课程中心:课程

**代码**
/ *
姓名:Matthew Gonzalez
Prog姓名:gonzalez_PA10
日期:4/27/05
目的:课程
* /

#include< iostream>
使用命名空间std; <
//类
类用户
{
私有:

int userId;
char firstName [20];
char lastName [20];
char密码[20];

使用std :: string而不是char数组会更好。

Hi, I''m a student learning C++ and my professor isn''t much help, her view is if you dont get it I ain''t helping you....

We are supposed to do a basic program as a logon system. I got as far as I could and came up with some errors I could not understand.

Any Help would be appreciated.
Using: MS Visual Studio .Net 2003
Language: C++
Program centers around: Classes
**CODE**
/*
Name: Matthew Gonzalez
Prog Name: gonzalez_PA10
Date: 4/27/05
Purpose: Classes
*/

#include <iostream>
using namespace std;

//class
class User
{
private:

int userId;
char firstName[20];
char lastName[20];
char password[20];

Using std::string instead of char arrays would be better.

public:

void setUserData(char firstName [20],char lastName [20],char
password [20]); void changePassword(char password [20],char newPass [20]);
void displayUser(int userId,char firstName [20],char lastName [20],char
password [20]);
};
//结束类
public:

void setUserData(char firstName[20],char lastName[20],char password[20]); void changePassword (char password[20],char newPass[20]);
void displayUser(int userId,char firstName[20],char lastName[20], char
password[20]);
};
//end class



用户:: setUserData(char firstName [20],char lastName [20],char



void User::setUserData(char firstName[20],char lastName[20],char



密码[20])


password[20])

{
cout<<"请输入您的名字:"<< endl;
cin> > firstName [20];
cout<<"请输入您的姓氏:"<< endl;
cin>> lastName [20];
cout< <"请输入您的密码:"<< endl;
cin>>密码[20];
//结束setuserdatafunction
}
void用户: :changePassword(char password [20],char newPass [20])
{
cout<<"Please Enter Your First Name: "<<endl;
cin>>firstName[20];
cout<<"Please Enter your Last Name: "<<endl;
cin>>lastName[20];
cout<<"Please Enter your Password: "<<endl;
cin>>password[20];
//end setuserdatafunction
}
void User::changePassword(char password[20],char newPass[20])
{
cout<<"请输入新密码"<< endl; < br> cin>> newPass [20];

if(密码[20] == newPass [20])
{
cout<<"你密码是一样的。不会发生变化。<< endl;
}

{
if(password [20]!= newPass [20])
< br> newPass [20] =密码[20];
}
}
{
cout<<"Please enter new password"<<endl;
cin>>newPass[20];

if(password[20]==newPass[20])
{
cout<<"Your password is the same. No Change will occur."<<endl;
}
else
{
if(password[20]!=newPass[20])

newPass[20]=password[20];
}
}



void User :: displayUser(int userId,char firstName [20], char lastName [20],



void User::displayUser(int userId,char firstName[20],char lastName[20],



char


char

password [20])
{
cout<<"用户ID是:"<<< userId<< endl;
cout<<"名字是:"<< firstName [20]<< endl;
cout< ;<""<<< lastName [20]<< endl;
cout<<""密码为:"<< password [20] << endl;
//结束显示用户功能
}
int main()
//
//用户对象
用户登录;
int userId;
char firstName [20];
char lastName [20];
char password [20];
char newPass [20];
char answer;

cout<<"请输入用户ID:"< < endl;
cin>> userId;
password[20])
{
cout<<"The User id is: "<<userId<<endl;
cout<<"The First name is: "<<firstName[20]<<endl;
cout<<"The Last name is: "<<lastName[20]<<endl;
cout<<"The password is: "<<password[20]<<endl;
//end display user function
}

int main()
{
//user object
User logon;
int userId;
char firstName[20];
char lastName[20];
char password[20];
char newPass[20];
char answer;

cout<<"Please enter a user Id: "<<endl;
cin>>userId;



logon.setUserData(firstName,lastName,password);



logon.setUserData(firstName, lastName, password);

cout< ;<您要更改密码吗?输入Y或N:"<< endl;
cin>> answer;
// if
if(answer ==''y'')
{
cout<<"Do you want to change your password? Enter Y or N: "<<endl;
cin>>answer;
//if
if(answer==''y'')
{



logon.changePassword(password,newPass);
logon.displayUser(userId,firstName,lastName,password);



logon.changePassword(password, newPass);
logon.displayUser(userId, firstName, lastName, password);

}


if(answer ==''n'')
{
}
else

if(answer==''n'')
{



logon.displayUser( userId,firstName,lastName,password);



logon.displayUser(userId, firstName, lastName, password);

}
// endif

返回0;
}
}
//endif

return 0;
}



修复它以进行编译。我没有检查甚至运行代码。


Just fixed it to compile. I did not check or even run the code.



gonzal51写道:
gonzal51 wrote:
我在想,(而我正在努力)我遇到的问题是什么?
I was wondering, (while I work on it) what were the problems I was having?







?


这篇关于程序帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆