Archived

This topic is now archived and is closed to further replies.

Link errors with statics

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Using MSVC++ 6, whenever i create a static variable for a class, it compiles fun but then i get a link error saying: "unresolved external symbol" followed by the name of the static i declared. If anyone can figure out what I''m doing wrong from this vague description, I''d be extremely grateful. I haven''t used statics all that much before, so it''s probably something pretty simple i''m not doing. Thanks a lot. MelvinElvin

Share this post


Link to post
Share on other sites
In case the previous poster''s message wasn''t clear (it is perfectly correct, but might be confusing, I suppose): The reason you are getting a linker error is because you are initializing the static variable in the header file, and not in the .cpp.

Statics should be initialized in the .cpp in which you define the class member functions.

Share this post


Link to post
Share on other sites