#include <iostream>
class B;
class A{
int a;
public:
friend void B::frndA();
};
class B{
int b;
public:
void frndA();
};
void B::frndA(){
A obj;
std::cout << "A.a = " << obj.a << std::endl;
}
int main() {
return 0;
}
When trying to compile this code, some errors occurred. E.g.
invalid use of incomplete type
What are the problems in this code?
friend
isn't one of the most helpful keywords. Alsoforward-declaration
makes more sense when combined in one tag. Edit: Oh andclass
also makes more sense thenfunction
I guess :) – Leffler