Use friend function from another cpp

57 Views Asked by At

I need to define a function in my .hpp file, declare it in my .cpp file and then use it in a second .cpp file that includes the first one.

My problem is that when I do all this, I get the error: "example" was not declared in this scope.

I don't understand what I'm doing wrong, can someone please help me?

base.hpp

    class Base {
public:
    static size_t b;
    Base() {};
    friend Base exemple(uint64_t value);
};

base.cpp

Base exemple(size_t value)
{
  Base res;
  Base::b = value;
  return res;
}

in the main of my second cpp (stack.cpp)

exemple(3);
0

There are 0 best solutions below