Using a static function without an instance of a class, in C ++

I have a class with static functions. I need to use functions without instantiating the class.

Is it possible?

+3
source share
3 answers

Of course:

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

...

A::f();    // call function
+17
source

No problem, that’s their point.

+1
source

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

+1
source

Source: https://habr.com/ru/post/1727935/


All Articles