Was macht RUNTIME_CLASS
-
Hallöchen,
was macht eigentlich das Makro RUNTIME_CLASS ? Und wann muss man es verwenden?
MfG Juhu
-
Gibt Dir Laufzeitinformationen der Klasse zurück. Wird gebraucht für dynamische Erstellung und Serialisierung
-
Aber dynamische Erstellung könnte man doch auch mit new machen oder ist damit etwas anderes gemeint?
-
Und was sind das für Laufzeitinformationen?
-
Mit dynamische Erstellung meine ich z.B.:
Den Namen der Klasse in ein Editfeld eingeben, und dann das Objekt erstellen lassen, ohne den Code zu ändern!
Infos about CRuntimeClass findest Du in der MSDN! Ich werde hier keine >2 Seiten MSDN-Text posten!
-
CRuntimeClass is a structure you can use to obtain information about an object or its base class at run time. The ability to determine the class of an object at run time is useful when extra type checking of function arguments is needed, or when you must write special-purpose code based on the class of an object. Each class derived from CObject is associated with a CRuntimeClass structure.
struct CRuntimeClass { LPCSTR m_lpszClassName; int m_nObjectSize; UINT m_wSchema CObject* (PASCAL* m_pfnCreateObject)( ); CRuntimeClass* (PASCAL* m_pfnGetBaseClass)( ); CRuntimeClass* m_pBaseClass; CObject* CreateObject( ); BOOL IsDerivedFrom(const CRuntimeClass* pBaseClass) const; };
Header file: Afx.h