mfc static classes

Hi all,
 

are all mfc classes(in the hiearchy chart provided by microsoft) STATIC in a wizard generated application???

p
struggling_coder_3203Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
To repeat my first post

Functions that are defined with a keyword static can be used by the following technique
int x = CMyClass::MyFnReturnSomeInt();

else you need
CMyClass ob;
int x = ob.MyFnReturnSomeInt();

and I posted this in response to your previous question about static functions

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.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
What do you mean by a class being static?

Functions that are defined with a keyword static can be used by the following technique
int x = CMyClass::MyFnReturnSomeInt();

else you need
CMyClass ob;
int x = ob.MyFnReturnSomeInt();
0
 
Jaime OlivaresSoftware ArchitectCommented:
I guess you are not utlizing correctly the term "static", could you explain with more detail what you want to know?
0
 
struggling_coder_3203Author Commented:
well, i mean, in order to used a classes functionality without instantiating an object of that class, the class must be defined as static. So, if I need to used some kind of functionality in an mfc class, I won't have to instantiate it if it is static.

0
 
Jaime OlivaresSoftware ArchitectCommented:
You don't have to instantiate a class as static, but you can use STATIC member (data and functions). If class doesn't have static members you can't use it without instantiating an object.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.