This topic is 2147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Im new to using extern variables and after trying to extern my Scene Manager and Resource Manager i end up getting linking errors.

The .h where i put the extern class instances looks like this
#pragma once #include "SceneManager.h" #include "ResourceManager.h" extern CResourceManager *Resources; extern CSceneManager *Scene;

and the declarations are in a different .cpp

but wherever i included the above hearder i get linking errors. did i make some mistakes in making the header?

##### Share on other sites
The header is fine, but they only include declarations. That is, they tell the compiler that at some point someone is going to define those variables. Now you need to go and do just that. In a single source file you need to define the global variables without the externs. In your case you'd have:
 CResourceManager *Resources; CSceneManager *Scene; 

##### Share on other sites
oh. riiiiiiiiiiight. thnx a lot. forgot i had to define them without the extern. i was just constructing them in the cpp without defining them. thnx a lot. works perfectly.

"Dam whoever invented singleton"

• 10
• 12
• 10
• 10
• 11