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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:21:22+00:00 2026-05-28T13:21:22+00:00

Let me start by saying I’ve extensively searched for answers on google and more

  • 0

Let me start by saying I’ve extensively searched for answers on google and more specifically here.

The thing is I actually (at least I think I did) found people with similar problems, though the answer given to them gave me another problem.

I’m using Visual Studio 2010 Express and working with SFML libary (though i do not think this last part is relevant)

So here it goes:

I have a source file called player.cpp which holds class Player and I have a header file (included in all source files) called cc.h(command and control) that holds all the necessary includes and external variables/functions. The essential code can be summed up in the following:

Player.cpp:

#include "cc.h"
class Player
{
private:

//some variables here

public:

//more variables and some functions

}john;//example instance

cc.h:

#pragma once

//some #includes
//some externs

extern Player john;

Now in cc.h the word Player is underlined as a mistake saying it is an undefined identifier , but only sometimes, other times visual studio doesn’t mark it as a mistake, instead it recognizes it as a class but doesn’t recognize john as an object/instance (i hope it’s called this way) of that same class.
Furthermore, at compiling the first error it shows is “error C2146: syntax error : missing ';' before identifier 'john'” at the line of the extern declaration of john, in cc.h, which apparently (to me) does not make any sense.

  • 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-05-28T13:21:23+00:00Added an answer on May 28, 2026 at 1:21 pm

    The global declaration in cc.h would not help you, I guess – because you declare it to access it from else where (other than Player.cpp), but for this you need the method signatures – a soon as you want to access john from elsewhere and thus include Player.cpp, you get duplicates symbols.

    Please consider creating a Player.h file where only the class and method signatures are declared – like this:

    #ifndef PLAYER_H_
    #define PLAYER_H_
    
    class Player
    {
         void doSomething();
    };
    #endif
    

    and add this to cc.h:

    #include <Player.h>
    extern Player john;
    

    and in your Player.cpp

    #include <Player.h>
    
    Player john;
    
    void Player::doSomething()
    {
        //...
    }
    

    This makes sure that the Player signatures are known and a valid instance is declared globally.

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

Sidebar

Related Questions

Let me start by saying, that I don't think there is a way to
Let me start by saying that I can't put any code here because Internet
First let me start off by saying I read on here a lot and
Let me start by saying this is a homework assignment, I don't need any
Let me start by saying that I've never coded in Python. I need to
Let me start by saying, I like the border that chrome is using for
Let me start by saying im not 100% the way Im handling this is
Let me start by saying that this app was working fine the day before.
Let me start by saying I'm new at programming, mac osx, and bash. I'm
Let me start by saying I'm very new to Java and to this site.

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.