Friend Function
#include<iostream>;
using namespace std;
class Home1 {
protected:
int Pass = 1234;
};
class Home :public Home1 {
friend void Tejas(Home);
private:
int Laptop = 1223;
protected:
int Pc = 90909;
public:
int Bike = 8888;
void display() {
cout << "Pass=" << Pass << endl;
}
};
void Tejas(Home obj2) {
cout << "Laptop=" << obj2.Laptop << endl;
cout << "PC=" << obj2.Pc << endl;
cout << "Pass=" << obj2.Pass << endl;
obj2.display();
}
int main() {
Home abc;
Tejas(abc);
return 0;
}
Comments
Post a Comment