#include <iostream>
class A {
public:
A(int val) : val(val) {}
protected:
int val;
};
class B : public A {
public:
B(int val) : A(val) {}
friendvoid print(const B&);
};
void print(const B& b) {
std::cout << b.val;
}
int main()
{
B b(3);
print(b);
return 0;
}
3
looks like yeah ;)
It has access to everything class B has access to which excludes private data of A