Master please advise
In the multi-document program, there is such a code in the key initialization function in INITINSTANCE ().
*********************************************************** **********
CMultiDocTemplate * pDocTemplate; pDocTemplate = new CMultiDocTemplate (IDR_PAINTETYPE, RUNTIME_CLASS (CPainterUsePatternDoc), RUNTIME_CLASS (CChildFrame), // custom MDI child frame RUNTIME_CLASS (CPainterUsePatternView)); AddDocTemplate (pDocTemplate);
*********************************************************** ***********
I haven't seen the runtime_class inside, what is the stuff?
Source code in Afx.h
*********************************************************** ***********
#define runtime_class (Class_name) (CRUNTIMECLASS *) (& class_name :: class ## class_name))
#define assert_kindof (Class_name, Object) / Assert ((Object) -> iskindof (runtime_class (class_name))))
*********************************************************** ***********
This definition I don't understand, "##" What is Dongdong? ? Check in MSDN
*********************************************************** ***********
#define paster (n) Printf ("token" #n "=% D", token ## n) int token9 = 9;
// Define PASTER (N) as Printf ("token" #n "=% D", token ## n)
// then Paster (9); // This function is equivalent to the following functions PrINTF ("token" "9" "=% D", token9);
// turn it into
Printf ("token9 =% D", token9); ********************************************* ********************
We understand that '##' actually connects two strings and returns to the definition of just now
#define runtime_class (Class_name) (CRUNTIMECLASS *) (& class_name :: class ## class_name))
Macro definition runtime_class (Class_name) is ((CRUNTIMECLASS *) (& class_name :: class ## class_name))
Class_name is a parameter representing a class name
CruntimeClass is a structure
Remove the address of a Class_name class to the address of the structure of Class ## Class_name to remove its class
Switch to struct cruntimeclass * type
(to be continued)