You cannot call non-static member functions inside a static function. The reason is simple: static function don't 'belong' to a particular instance of the class (they don't receive the this parameter), thus, you can only access members (functions and variables) that doesn't belong to a particular instance also (so only static members).
The solution to remove the static but I don't think this will solve the problem. In general, there is a way to explicitely pass the this parameter so that the function can use this parameter and call a public function from that particular instance.
Should work just fine. Never be afraid to go old-school instead of jumping through so many hoops just to use MFC's version of something.
-=- JamesIf you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
Nope. You are returning the address of a temporary string. Thus, the memory is not protected anymore. Sure, the pointers still 'points' at a the same address but the contents are not protected anymore, thus they can be overwritten.
I don't think we have the same notion of safety .
Sorry, but it is not safe: sure, the pointer still 'points' at the same address but the contents of the strings are not protected anymore (we are out of the scope of the function in which the string was local). You save this address in another pointer but that doesn't change the fact that the memory is still unprotected.
So, later in your program you may find garbage characters in your string and you don't know way. It is like using a string allocated with new after having deleted it.
String literals are statically allocated, ie. memory is allocated for them when the application is loaded. The string is valid throughout the lifetime of the application. This would of course be different if he was allocating a string on the stack.