Hey DaniWeb :)

So Im working on this C++ Project and I'm getting this wierd LINKER issue. So basically this is the scenario

1. non-static member (int) frame in Main.cpp
2. static get/set functions for frame in Main.h
3. I try to access the frame integer variable via the get functions (accessor) and I get an unresolved external error.. although, I have included the Main.h file.

Thanks :)
Hopefully this is enough information :)

can't really say the problem without seeing main.h. You probably did not write the implementation of those methods. In any event, get/set methods should not be static because static methods do not have access to instance data.

Oh eh.. implementaion being definitions, yes. I did define them. I don't understand the second part tho :P

Can you tell me the general reason as to why this error would occur ?

Edit: ... I get the instance thing now.. So then is there any other way to get instance data without creating another instance of Main ? :S Or would this require me to create the variable in a different object ? ... Even then I don't believe it would solve my problem :S

Singleton Pattern or make the entire class static.

Personally I prefer the singleton pattern, but without seeing your code it's difficult to judge. As you mention "main", I can hazard a guess that this contains your application instance that you're launching from the entry point. In which case, Singleton would be much better. (In fact, there aren't many reasons I can think of for making an entire class static, without it being part of the singleton pattern)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.