Search This Blog

Sunday, 23 August 2020

Frioend function without sccope resolution

 #include<iostream>

#include<conio.h>

using namespace std;

class A;

class B

{

int b;

public:

void getval(int x)

{

b=x;

}

putval(void)

{

cout<<"\n Value of B is:"<<b;

}

friend void add(A,B);

};

class A

{

int a;

public:

void getval(int x)

{

a=x;

}

void putval(void)

{

cout<<"Value of A :"<<a;

}

friend void add(A,B);

}

void add(A obj1,B obj2)

{

cout<<"Addition of A and B is : "<<obj1.a+obj2.b;

}

int main();

A a;

B b;

a.getval(100);

b.getval(200);

a.putval();

b.putval();

add(a,b);

getch();

return 0;


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts