MY name is ruhul amin

ISLAMIC UNIVERSITY OF KUSHTIA

Thursday, March 28, 2013

www.use of friend class

#include <iostream>
#include<cstring>
#define max 1000
using namespace std;
class name1
{
    private:
    char a[max];
    char b[max];
    int la,lc;
    public:
    void member()
    {
        cin.get(a,max);
        la=strlen(a);
        lc=la;
        for(int i=0;i<la;i++)
        b[i]=a[i];
    }
    friend class name2;
};
class name2
{
    private:
    char c[max];
    int lb;
    public:
    void member1(name1&la)
    {
        lb=la.lc;
        for(int j=0;j<lb;j++)
        {
        c[j]=la.b[j];
        cout<<c[j];
        }
        cout<<"\n";
    }
    friend class name3;

};
class name3
{
    private:
    char string[max];
    int ld;
    public:
    void member2(name2&lk)
    {
    ld=lk.lb;
    for(int k=ld-1;k>=0;k--)
    {
    string[k]=lk.c[k];
    cout<<string[k];
    }
    cout<<endl;
    }
};

int main()
{
    name1 ob;
    name2 ot;
    name3 om;
    ob.member();
    ot.member1(ob);
    om.member2(ot);
    return 0;
}

No comments:

Post a Comment