I’m starting to learn windows programming in C++. I’ve been coding c++ console applications for some time. My question is, if I have a class:
class Example
{
int x;
char* y;
};
And want to use it in my GUI application. Should I change the types of Example members to the
Windows-specic types? Or should I use windows type only in the parts of the program that are directed related to the GUI? Which is the best practice?
The answer to this may be somewhat based on preference and use case. If you are going to be passing data from your objects into the windows API, it may make sense to have your data-types match the windows data types.
On the other hand, we have some code that is platform specific (for example Windows or Mac GUI code) and some code which is portable. In the portable code, we try to stick to C/C++ types, and in the platform specific code, we will use the platform-specific types.
So the short answer is there is no right answer, but I personally would try to stick to C/C++ types as much as possible based on my experience with porting applications.