miko
miko

Reputation: 31

using a static function without an instance of the class, in c++

i have a class with static functions. i need to use the functions without creating an instance of the class.

is it possible?

Upvotes: 3

Views: 2625

Answers (3)

ChRapO
ChRapO

Reputation: 337

Or you can use the singleton design pattern: http://en.wikipedia.org/wiki/Singleton_pattern#C.2B.2B

Upvotes: 1

Viktor Sehr
Viktor Sehr

Reputation: 13099

No problem at all, thats the point of them.

Upvotes: 1

anon
anon

Reputation:

Sure:

class A {
   public:
      static void f();
};

...

A::f();    // call function

Upvotes: 17

Related Questions