How to call C++ static method

Use :: instead of .

MyObject o = MyMath::calcSomething();

When you are calling the method without the object of the class you should use :: notation. You may also call static method via class objects or pointers to them, in this case you should use usual . or -> notation:

MyObject obj;
MyObject* p = new MyObject();

MyObject::calcSomething();
obj.calcSomething();
p->calcSomething();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)