error meaning

This is a discussion on error meaning within the C++ Programming forums, part of the General Programming Boards category; Hello, What does this mean? Code: function call missing argument list; use '&Player::viewProfile' to create a pointer to member Thanks!...

  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
    21,589
    What is the relevant function declaration and function call?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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 12:15 AM. Reason: posted wrong code

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,589
    How are you calling this member function?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    21,589
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21