I\'m trying to create a method in a C++ class that can be called without creating an instance of the class (like a static method in Java), but I keep running into this error
In C++ it's
Method::printStuff();
and you have to declare the method as static
.
class Method{
public:
static void printStuff(void){
cout << "hahaha!";
}
};
::
is called the scope resolution operator. You can call the method with .
if it's on a class instance, but the instance is not required (it being static and all...).