Win32 programming uses a wide range of structures. Many times, only some of their fields are used, and all other fields are zero. For example:
STARTUPINFO startupInfo;
ZeroMemory( &startupInfo, sizeof( startupInfo ) );
startupInfo.cb = sizeof( startupInfo );
startupInfo.dwFlags = STARTF_FORCEOFFFEEDBACK;
I want to stop copying such code and use an abstraction instead, which will take care of zeroing and settings. Suppose I only need a structure initialized, as in the example, and no other configuration is required. Is the following a good solution? What are the possible problems?
class CStartupInfo : public STARTUPINFO {
public:
CStartupInfo()
{
ZeroMemory( this, sizeof( STARTUPINFO ) );
cb = sizeof( STARTUPINFO );
dwFlags = STARTF_FORCEOFFFEEDBACK;
}
};
ZeroMemory() - , , vtable ZeroMemory() , , , , . - ?