Never define global variables in .h files! You can declare these variables, of course - simply use extern keyword before its type, but define such variables in one and only only cpp file.
As usually, there are better solutions than global variables using, but it's the other story.
The key question in your case: who (and when) must initialize (global?) mysampleclass pointer variable? I don't know the answer because your snippet is too laconic.
It seems you have too cumbersom mechanics for a simple task. May be you present more codes and better your program case description?
Reputation Points: 1234
Solved Threads: 347
Postaholic
Offline 2,001 posts
since Jul 2008