weird error when calling function in other class?

Hi,

With this code in class1:

class2::myFunction();

I hoped to call a function in class 2:

1
2
3
4
5
void class2::myFunction()
{
    printf("myFunction");
    
}


Each is in its own file, and the error thrown is:

call to a nonstatic member function without an argument

Sorry if this is painfully obvious, but could someone tell me what I'm doing wrong?
Last edited on
The method myFunction() isn't static, so you need an instant of class2 to call it.
1
2
class2 obj;
obj.myFunction();
Make that "myFunction()" a static member, meaning you can call its methods without instantiating it. If you have done so, are you including the header with the class definition.
Last edited on
Topic archived. No new replies allowed.