#include <iostream>
using namespace std;
class Base
{
private:
int x;
protected:
int y;
public:
Base(int a,int b):x(a),y(b)
{
cout<<"contructor called"<<endl;
}
friend class Temp;
};
class Temp
{
public:
void func(Base &b)
{
cout<<"The value of x is "<<b.x<<endl;
cout<<"The value of y is "<<b.y<<endl;
}
};
int main() {
Base b(10,20);
Temp t;
t.func(b);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: