You are here:

C++/Since only one copy of each method is stored, what is the difference between static methods and normal methods?

Advertisement


Question
Hi,

Since only one copy of each method is stored, what is the difference between static methods and normal methods?

Thanks,
lzzzz

Answer
Hello lzzzz, thank you for the question.

Static methodsdo not have a "this" pointer. That is the primary major difference. This means that theoretically, you could invoke a static method from a class while the invoking object is NULL and it won't crash, as long as you do not manipulate any member data of the class. Of course, I've only seen this done on one compiler and on my specific CPU and operating system, but it is feasible.

If you have any other questions, please do not hesistate to ask.

I hope this information was helpful.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.