Static Member Functions

  • Thread starter RainerFaulstich
  • Start date
R

RainerFaulstich

Hi,
Some dummy question :
Are static member functions of a class indeed a single instance for all
instances of the class or have difference instances of this class have its
own instances of this function?

Rainer
 
J

John Harrison

RainerFaulstich said:
Hi,
Some dummy question :
Are static member functions of a class indeed a single instance for all
instances of the class or have difference instances of this class have its
own instances of this function?

Rainer

You misunderstand. All member functions exist as only one instance, static
or non-static.

The difference between a non-static member function and a static member
function is that the this keyword is not usable in a static member function.
Think of the this keyword as an extra hidden parameter which every
non-static member function has (and in fact that is how it is normally
implemented).

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top