Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:01:08+00:00 2026-06-04T12:01:08+00:00

I am getting an error ‘return type does not match function type’ when I

  • 0

I am getting an error ‘return type does not match function type’ when I am trying to return a pointer to a player in my function. The error from the compiler is:

‘&’ : illegal operation on bound member function expression

CPlayer* CLevel::getPlayer()
{
return &player;
}

In the header file, this is defined as:

private:
    CPlayer player(Point p, CGame* game);

public:
    CPlayer* getPlayer();

Any ideas as to why I am getting this error and how I can remove it?

EDIT:

Level constructor:

CLevel::CLevel()
{
Point p;
this->game=game;
p.x=0;
p.y=0;
player(Point p, CGame* game) {};

memset(tiles, GROUND, sizeof(TileType)*GRID_HEIGHT*GRID_WIDTH);
}

Player.cpp constructor:

 CPlayer::CPlayer(Point pos, CGame* game)
 {
this->game=game;
Point p;
p.x=0;
p.y=0;
setPosition(p);
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:01:09+00:00Added an answer on June 4, 2026 at 12:01 pm

    Because in your code, player is the name of a private function:

    private:
        CPlayer player(Point p, CGame* game);
    

    This is a function that takes a Point, a CGame*, and returns a CPlayer.

    To declare a CPlayer data member you need

    private:
        CPlayer player;
    

    which you can then initialize in the constructor, for example:

    CLevel(Point p, CGame* game) : player(p, game) {}
    

    and:

    CLevel() : player(Point(), game) {
      this->game = .... ;
    }
    

    Or, in C++11, you can do it like this:

    private:
        CPlayer player{Point(), nullptr}; // I am not sure where you were getting p and game in your original example
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting error from devise User does not respond to 'devise' method when running
I am getting error as Entitlements does not match. Here I am using developers
i am getting error : Error 1 The type or namespace name'CreateUser' does not
I'm getting error Not unique table/alias while trying to display data from MySQL database
getting error: ActiveRecord::StatementInvalid (PGError: ERROR: argument of HAVING must be type boolean, not type
I'm getting error using the following code snippet jQuery(document).ready(function() { jQuery.ajax({ url: url, type:
i am getting error: cannot convert to pointer type NSMutableDictonary *mydictonary; [mydictionary setValue: [mySlider.value
I am getting error while deserializing jsonString. Error is Type 'oodleListingsUser' is not supported
I am getting SMTP Error: Could not connect to SMTP host. error while trying
I am getting error schema does not yet agree while creating new key-space on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.