Thursday, 29 April 2021

main() function as a friend in C++

 #include<iostream.h>

#include<conio.h>

class A

{

int a, b;

void display()

{

cout<<"Display"<<endl;

}

public:

void display1()

{

cout<<"Display-1"<<endl;

}

friend int main();

};


main()

{

clrscr();

A ob;

ob.display();

ob.a=5;

ob.b=10;

cout<<ob.a+ob.b<<endl;

ob.display1();

getch();

return 0;

}

No comments:

Post a Comment