Click here to Skip to main content
15,851,387 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello once again,

Today I have more "writing style" question:

When I have class, should I specify
#ifdef UNICODE
#define CClass CClassW
#else
#define CClass CClassA
#endif 

and create two versions of same class?
Or rather define the data types inside the class?
Like:
#ifdef UNICODE
CMap<CString, LPCWSTR, DWORD, DWORD> m_SomeMap;
#else
CMap<CString, LPCSTR, DWORD, DWORD> m_SomeMap;
#endif 


Appreciate all advices,

Thanks
Posted

1 solution

Creating different names of classes for unicode and non-unicode doesn't make sense.

It's the string data type that really matters here.
So your CMap example makes sense because it contains a character pointer.
You might as well use -
CMap<CString, LPCTSTR, DWORD, DWORD> m_SomeMap;


LPCTSTR translates to LPCSTR or LPCWSTR depending on whether UNICODE is defined or not.

I would personally recommend always using the wide version of strings because Windows internally uses these and also because you're going to need them somewhere sometime.
 
Share this answer
 
Comments
Nish Nishant 11-Jul-10 0:24am    
Reason for my vote of 5
Quality answer!
Im2N00By 11-Jul-10 9:34am    
Thank you for answer. Very helpful. I will try to work out the best solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900