Sunday, 15 September 2013

PROGRAM OF FRIEND FUNCTION

/*MADE BY KRISHNA AGARWAL*/
#include<iostream>
#include<conio.h>
using namespace std;
class A
{
    int a;
    int b;
    int c;
public:
    void getdata()
    {
        cout<<"enter the value of a \n";
        cin>>a;
        cout<<"enter the value of b \n";
        cin>>b;
        cout<<"enter the value of c \n";
        cin>>c;
    }
    void putdata()
    {
        cout<<"\nthe value of a is  "<<a;
        cout<<"\nthe value of b is  "<<b;
        cout<<"\nthe value of c is  "<<c;
    }
    friend int product(A obj);
};
int product(A obj)
{
    int c;
    c=obj.a*obj.b*obj.c;
    return c;
}
main()
{
    A obj1;
    obj1.getdata();
    obj1.putdata();
    cout<<"\nthe product is "<<product(obj1);2
    return 0;
}

No comments:

Post a Comment