To call a class method/function from a .hxx file in a .cpp file

How do I call a class method which is defined in a .hxx file separately to a .cpp file? Is it any different from how we normally do it (using the scope resolution operator after the class name and then the method name with parameters) ?
Last edited on
if you want to define it in the cpp file, then you should use the scope operator.

X.hpp :
1
2
3
4
struct X
{
    int f() const;
};

X.cpp
1
2
3
4
#include "X.hpp"

int X::f() const
{ return 25; }


Otherwise, if you want to call it :
1
2
3
4
5
6
7
#include "X.hpp"

int a_function( )
{
    X x;
    return x.f(); // <===== call ======>
}


Does this help ? feel free to ask more
Last edited on
Topic archived. No new replies allowed.