> 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....
[quoted text clipped - 28 lines]
> char lastName[20];
> char password[20];
Using std::string instead of char arrays would be better.
> public:
>
[quoted text clipped - 4 lines]
> };
> //end class
void User::setUserData(char firstName[20],char lastName[20],char password[20])
> {
> cout<<"Please Enter Your First Name: "<<endl;
[quoted text clipped - 5 lines]
> //end setuserdatafunction
> }
void User::changePassword(char password[20],char newPass[20])
> {
> cout<<"Please enter new password"<<endl;
[quoted text clipped - 11 lines]
> }
> }
void User::displayUser(int userId,char firstName[20],char lastName[20], char
> password[20])
> {
[quoted text clipped - 18 lines]
> 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.
gonzal51 - 02 May 2005 03:24 GMT
I was wondering, (while I work on it) what were the problems I was having?
> > 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....
[quoted text clipped - 121 lines]
>
> Just fixed it to compile. I did not check or even run the code.
Ioannis Vranos - 02 May 2005 06:13 GMT
> I was wondering, (while I work on it) what were the problems I was having?
?
gonzal51 - 02 May 2005 13:25 GMT
I meant, while I load it into my visual.NET and physically look at it as
well as changes you've made (thanks!). Although I found that while it
compiles, I can enter an userId, and FirstName, but soon after it shows the
other outputs, i'm guessing its a problem with my SetUserData function. Such
is what I meant by working on it. :-)
> > I was wondering, (while I work on it) what were the problems I was having?
>
> ?
Mihajlo Cvetanovic - 02 May 2005 09:27 GMT
> I was wondering, (while I work on it) what were the problems I was having?
>
>>void User::setUserData(char firstName[20],char lastName[20],char
When you omit return type (void in this case) the default type is int,
so the compiler expects that you actually return something (return 0).
Since you don't return anything compiler calls it an error.
>> logon.setUserData(firstName, lastName, password);
When you call a function you put arguments in argument list. But "char
firstName[20]" is not an argument. "firstName" is an argument. To the
compiler "char firstName[20]" looks like a declaration, but the whole
line doesn't look like anything recognizable, that's why it's confused
and reports an error.
Ioannis Vranos - 02 May 2005 11:00 GMT
> When you omit return type (void in this case) the default type is int,
> so the compiler expects that you actually return something (return 0).
> Since you don't return anything compiler calls it an error.
I think you are probably talking about pre-standard C++. By omitting the return type, no
int is implied, it is an error. :-)
Mihajlo Cvetanovic - 02 May 2005 12:05 GMT
> I think you are probably talking about pre-standard C++. By omitting the
> return type, no int is implied, it is an error. :-)
Alas, VC71 assumes int and gives only warnings, C4183 for member
functions and C4508 for global functions, but it wouldn't be an error to
treat is as such :-)
Ioannis Vranos - 02 May 2005 12:14 GMT
> Alas, VC71 assumes int and gives only warnings, C4183 for member
> functions and C4508 for global functions, but it wouldn't be an error to
> treat is as such :-)
Let's use some simple code:
class SomeClass
{
public:
void somefunc();
}
SomeClass::somefunc() {}
int main()
{
}
Do you get such warnings for this?
For this
class SomeClass
{
public:
somefunc();
}
SomeClass::somefunc() {}
int main()
{
}
I get such a warning, but it is followed by bizarre errors and does not compile either. :-)
Ioannis Vranos - 02 May 2005 12:18 GMT
> For this
>
> class SomeClass
> {
> public:
> somefunc();
};
> SomeClass::somefunc() {}
>
[quoted text clipped - 4 lines]
> I get such a warning, but it is followed by bizarre errors and does not
> compile either. :-)
I had omitted the ';' in the class definition. Yes you are right, it gives such a warning
and compiles. However this is not standard C++ behaviour, you may consider it as a system
extension (which probably would be better to be fixed sooner or later). :-)
gonzal51 - 02 May 2005 13:30 GMT
Thanks for the info. I appreciate it.
"> >> logon.setUserData(firstName, lastName, password);
> When you call a function you put arguments in argument list. But "char
> firstName[20]" is not an argument. "firstName" is an argument. To the
> compiler "char firstName[20]" looks like a declaration, but the whole
> line doesn't look like anything recognizable, that's why it's confused
> and reports an error.