CRuntimeClass
-
Hi, the symbol :: puzzles me. I already know that this is a scope resolution operator which is used to execute a parent class method from within a subclass method. Plz look here, return &class_name::class##class_name; Note: ## is used to connect two separated string. class##class_name is NOT a method, and &class_name::class##class_name in all means a pointer to a CRuntimeClass struct. There are others, COjbect::classCObject, CCmdTarget::classCCmdTarget,etc. What doest :: mean here?? :rolleyes: Best regard. I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
-
Hi, the symbol :: puzzles me. I already know that this is a scope resolution operator which is used to execute a parent class method from within a subclass method. Plz look here, return &class_name::class##class_name; Note: ## is used to connect two separated string. class##class_name is NOT a method, and &class_name::class##class_name in all means a pointer to a CRuntimeClass struct. There are others, COjbect::classCObject, CCmdTarget::classCCmdTarget,etc. What doest :: mean here?? :rolleyes: Best regard. I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
NicholasCougar wrote: What doest :: mean here?? It means just what you said this is a scope resolution operator In a macro,
#define MYMACRO(class_name)\
class_name::class##class_name
used asMYMACRO(CMyClass);
evaluates toCMyClass::classCMyClass
Of course,classCMyClass
has to be declared inCMyClass
-
NicholasCougar wrote: What doest :: mean here?? It means just what you said this is a scope resolution operator In a macro,
#define MYMACRO(class_name)\
class_name::class##class_name
used asMYMACRO(CMyClass);
evaluates toCMyClass::classCMyClass
Of course,classCMyClass
has to be declared inCMyClass
And you'll find the classCMyClass member is declared and defined in the DECLARE/IMPLEMENT_DYNCREATE macros. Sorry to dissapoint you all with my lack of a witty or poignant signature.
-
NicholasCougar wrote: What doest :: mean here?? It means just what you said this is a scope resolution operator In a macro,
#define MYMACRO(class_name)\
class_name::class##class_name
used asMYMACRO(CMyClass);
evaluates toCMyClass::classCMyClass
Of course,classCMyClass
has to be declared inCMyClass
Hi, From MSDN, :: is scope resolution operator for executing METHOD declared in superclass. But classCMyClass is not a METHOD, but a STRUCT. Can :: be used in this way? Best regard. I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
-
Hi, From MSDN, :: is scope resolution operator for executing METHOD declared in superclass. But classCMyClass is not a METHOD, but a STRUCT. Can :: be used in this way? Best regard. I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
:: is not only used to specify superclass methods. It can be used to: Specify methods in your own class, Specify class methods (static) in any class, Resolve namespaces, Reference instance and class member variables, Specify any nested classes, structs, enums, etc. All it really does is give the location of a specific item. E.g. std::cout // specifies that cout is in the std namespace class C { enum E { num1 }; static void sfunc(); }; void func(C::E num); // specifies the type E in class C func(C::num1); // calling function with class C's enum value num1 C::sfunc(); // calling class C's static function sfunc() etc... Hope that helps.