A friend function can't be recognized
#include <iostream>
#include <cmath>
class hello {
private:
int a, b;
public:
hello(int a, int b) {
this->a = a;
this->b = b;
}
friend int add();
};
int add() {
return a + b;
}
int main() {
hello number(1, 2);
std::cout << number.add();
}
Expected: It should add the 2 membervariables of the class hello (with the friend function!)
Actual result: The friend function "add" is not recognized as a class member
(error message: error: 'class hello' has no member named 'add')
The a and b in add() aren't recognized too. (obviously)