I am looking for information about static methods in C++. I searched but honestly was not able to clearly understand a thing.
Are static functions those functions which contain static data members only?
Static methods of a class have no this
pointer. That means they cannot access instance member data. Methods (static or otherwise) do not contain data members. (They can declare variables on the stack or heap, however.)
Static methods are usually called with the class name (myClass::foo()
) since you don't have to declare an instance of the class to use them, but can be called with the instance (myInstance.foo()
) also.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments