Link to home
Start Free TrialLog in
Avatar of struggling_coder_3203
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?

ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of struggling_coder_3203
struggling_coder_3203

ASKER

so an object of a class must be instantiated in order to use the functionality???
If you plan to use non-static functions, definitively YES.
Avatar of AndyAinscow
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.
so, are all mfc classes static in a wizard generated application????????????????????????????