struggling_coder_3203
asked on
utilizing mfc class functionality
hi all,
Is it right that you can use the functionality of a class even though you don't instantiate that class and create an object?? For example, when you use AfxGetApp() function, it returns a pointer to a CWinApp class. But if I never instantiated an object of that class, then what is it pointing to?
Is it right that you can use the functionality of a class even though you don't instantiate that class and create an object?? For example, when you use AfxGetApp() function, it returns a pointer to a CWinApp class. But if I never instantiated an object of that class, then what is it pointing to?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you plan to use non-static functions, definitively YES.
Functions can be defined as static and, by default, non-static.
Roughly a static function does not require any initialisation that would be performed in the constructor of the class. This allows one to call a static function of a class without it being instantated.
Give it a try - create a new class yourself and do something like in the header
static int MyStaticFn() {return 2;};
now in your prog do
int x = CMyTestClass::MyStaticFn() ;
x now has the value 2.
Roughly a static function does not require any initialisation that would be performed in the constructor of the class. This allows one to call a static function of a class without it being instantated.
Give it a try - create a new class yourself and do something like in the header
static int MyStaticFn() {return 2;};
now in your prog do
int x = CMyTestClass::MyStaticFn()
x now has the value 2.
ASKER
so, are all mfc classes static in a wizard generated application??????????????? ?????????? ???
ASKER