How to call void from a different class?




GUI.cc
 
  SomeClass::Dothing(); //A nonstatic member reference must be relative to a specific object 


SomeClass.cpp
1
2
3
4
5
6
  class SomeClass
{
  public:
  void Dothing(); //This is what I want to use.

}
Last edited on
First, minor terminology critique: You don't call 'void', you call a function (which happens to have a return type of void).

If a class member function is not static, you need an instance of that class (an object), for the function be called on.

1
2
3
4
5
int main()
{
    SomeClass somebody;
    somebody.Dothing();
}


Otherwise, make the function static.
1
2
3
4
5
class SomeClass
{
  public:
  static void Dothing();
};
Last edited on
Topic archived. No new replies allowed.