Accessing members of parent class
If I have two different classes that are both derived from the same parent class, is it possible for one class to access the parent members of the other class? Example:
Code:
#include <iostream>
using namespace std;
class Parent
{
protected:
int value;
};
class Child_A : public Parent
{
public:
void Foobar(Parent &other) { cout << other.value << endl; }
};
class Child_B : public Parent
{
};
int main()
{
Child_A a;
Child_B b;
a.Foobar(b);
return 0;
}
This gives me "int Parent::value is protected". Is it possible in another way?