Hello,
What does this mean?
Thanks!Code:function call missing argument list; use '&Player::viewProfile' to create a pointer to member
Hello,
What does this mean?
Thanks!Code:function call missing argument list; use '&Player::viewProfile' to create a pointer to member
What is the relevant function declaration and function call?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Hi laserlight,
Here is the function. It's actually a class method. I have also declared mName and mHitPoints private. Do I need to use a pointer for this?
Thanks!Code:void Player::viewProfile() { cout << "Enter your player's name: "; getline(cin, mName); cout << "Would you like to view your profile? [Y/N]: "; char input = 'y'; cin >> input; if (input == 'N' || input == 'n') { cout << endl << "You chose not to view your profile.." << endl << endl; } else { cout << endl << "YOUR PROFILE: " << endl << endl; cout << "Name: " << mName << endl; cout << "Current Hit Points: " << mHitPoints << endl << endl; } }
Last edited by alyeska; 02-25-2009 at 01:15 AM. Reason: posted wrong code
How are you calling this member function?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I was just calling it from main like so:
I really appreciate your wanting to help. Thanks!Code:Player profile; profile.viewProfile;
Ah, you forgot the parentheses for the function call, i.e., you should write:
That said, I am of the opinion that functions that prompt the user for input are probably better off as non-member non-friend functions, or member functions in another class, if need be.Code:Player profile; profile.viewProfile();
The idea is that the Player class would model what you need to model about a Player, and then you would have functions that use the Player class. This way you can reuse the Player class and leave out the functions that get user input from the command prompt should you decide to implement a GUI instead.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Okay, thanks a lot, laserlight!