Are static member functions ever used?

Started by
13 comments, last by Cornstalks 11 years ago

And I'm not sure that will compile either since you can't call a function outside of a function body unless it is as an initializer for a global or static object... unless that's new in C++11

This does indeed compile, at least with the inofficial VS november 2012 compiler with extended c++11 support. Didn't know about that restriction though, but might really be c++11.

Advertisement

And I'm not sure that will compile either since you can't call a function outside of a function body unless it is as an initializer for a global or static object... unless that's new in C++11

This does indeed compile, at least with the inofficial VS november 2012 compiler with extended c++11 support. Didn't know about that restriction though, but might really be c++11.

Doesn't compile in GCC:

http://ideone.com/AWMOUV

Doesn't compile in GCC:

http://ideone.com/AWMOUV

I was talking about my code, the second half of paradigm shifter's post with the confusing "family" naming convections ;)

If you declare global static object in c/cpp file "static type gObjectName;" you cannot link the object from the header file by calling "extern type gObjectName;".

If you declare global static object in c/cpp file "static type gObjectName;" you cannot link the object from the header file by calling "extern type gObjectName;".

Good example of static, bad example of a static *member* function :)

I just wrote a static method in my Matrix class. The static identity() member function returns the identity matrix.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

This topic is closed to new replies.

Advertisement