Thread: error meaning

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    error meaning

    Hello,

    What does this mean?

    Code:
    function call missing argument list; use '&Player::viewProfile' to create a pointer to member
    Thanks!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What is the relevant function declaration and function call?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91
    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?

    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;
    	}
    }
    Thanks!
    Last edited by alyeska; 02-25-2009 at 01:15 AM. Reason: posted wrong code

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    How are you calling this member function?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91
    I was just calling it from main like so:

    Code:
    Player profile;
    	
        profile.viewProfile;
    I really appreciate your wanting to help. Thanks!

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Ah, you forgot the parentheses for the function call, i.e., you should write:
    Code:
    Player profile;
    
    profile.viewProfile();
    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.

    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91
    Okay, thanks a lot, laserlight!

Popular pages Recent additions subscribe to a feed