const TCHAR* to TCHAR*
-
Which is the right way to do and why? TCHAR *gClassName = 0; bool CreateCabinetMainWindow(const TCHAR* classname) { DeleteCabinetMainWindow( ); gClassName = (TCHAR*)classname; } OR const TCHAR *gClassName = 0; bool CreateCabinetMainWindow(const TCHAR* classname) { DeleteCabinetMainWindow( ); gClassName = classname; } Thanks in advance, Nandu
-
Which is the right way to do and why? TCHAR *gClassName = 0; bool CreateCabinetMainWindow(const TCHAR* classname) { DeleteCabinetMainWindow( ); gClassName = (TCHAR*)classname; } OR const TCHAR *gClassName = 0; bool CreateCabinetMainWindow(const TCHAR* classname) { DeleteCabinetMainWindow( ); gClassName = classname; } Thanks in advance, Nandu
Second option makes more sense. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Which is the right way to do and why? TCHAR *gClassName = 0; bool CreateCabinetMainWindow(const TCHAR* classname) { DeleteCabinetMainWindow( ); gClassName = (TCHAR*)classname; } OR const TCHAR *gClassName = 0; bool CreateCabinetMainWindow(const TCHAR* classname) { DeleteCabinetMainWindow( ); gClassName = classname; } Thanks in advance, Nandu
Second one. If you're declaring gClassName as mutable, then assigning an immutable string pointer to it is a bad idea. If you try to write to gClassName, then you could easily get an access violation if you'd called
CreateCabinetMainWindow
like this:if (CreateCabinetMainWindow(_T("MyClass"))) { .... };
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Second one. If you're declaring gClassName as mutable, then assigning an immutable string pointer to it is a bad idea. If you try to write to gClassName, then you could easily get an access violation if you'd called
CreateCabinetMainWindow
like this:if (CreateCabinetMainWindow(_T("MyClass"))) { .... };
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p