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 8987107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:42:38+00:00 2026-06-15T21:42:38+00:00

Hey I’m trying to pass a class object that I have made into another

  • 0

Hey I’m trying to pass a class object that I have made into another class to read that data. The error I’m getting is c2061: syntax error: identifier ‘Player’

This is my Player2.h

#pragma once
#include "DarkGDK.h"
#include "Input.h"
#include "Player.h"

class Player2{
public:
    Player2();
    void PlayerSetup();
    void PlayerUpdate(Player& user1);
    void PlayerHealthReset();
    void Gravity();
    float GetPosX();
    bool CheckMatchEnd();
    void PlayerFire(Player& user1);
    void PlayerCheckHitEnemies(Player& user1);
private:
    float Vx;
    float Vy;
    float PosX;
    float PosY;
    float Speed;
    int Lives;
    int Health;
    //  
    int gravity;
    bool playerJumping;
    bool matchEnd;
    bool playerIsFiring;
    float playerBullet;
    bool directionBullet;
};

And the error I’m getting is that It can’t recognize Player even though I brought in the Player header.

Here is Player.h

class Player{
public:
    Player();
    void PlayerSetup();
    void PlayerUpdate(float PosX2);
    void PlayerHealthReset();
    float GetPosX();
    float GetPosY();
    void Gravity();
    bool CheckMatchEnd();
    void PlayerFire(float PosX2);
private:
    float Vx;
    float Vy;
    float PosX;
    float PosY;
    float Speed;
    int Lives;
    int Health;
    float playerBullet;
    bool playerIsFiring;
    int gravity;
    bool playerJumping;
    bool matchEnd;
    bool directionBullet;
};

All the respective code within the header file works 100%, as I’ve tested it.

  • 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-15T21:42:40+00:00Added an answer on June 15, 2026 at 9:42 pm

    player does not compile before player2 is defined, so placing class player above your player2’s declaration will compile player BEFORE moving onto player 2.

    class player;
    class player2{
    //...
    }; 
    

    -Also as Hunter McMillen suggested think about making player 2 inherit from a base class, maybe player that defines standard methods all players would use(I dont want to steal hunter’s idea, i’ll let him post answer about this if he pleases with a more in depth approach).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I have a object sitting in my tile map for spawn point
Hey everyone I have a basic search function here that allows me to search
Hey I am getting this error: error: conversion to non-scalar type requested Here are
Hey I'm building an app that will allow a user to log into a
Hey all i am wondering why i am getting this error with the following
Hey guys I have this page : PS: this is temp data, so it
Hey guys so I am trying to have a loop run to get all
Hey, I have a problem sharing a link on twitter: data-url=http://ipofmywebsite/mypage/?some_id=276&some_name=b+a As I put
hey i got a contnet type that i made and i want to twweak
Hey I'm trying to creare a link that passes the link's text directly to

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.