Subscribe Us

Responsive Advertisement

Advertisement

class to class type coversion

 

class to class type coversion



#include<bits/stdc++.h>

using namespace std;

class item1

{

    int x,y;

public:

    item1(){}

    item1(int a,int b)

    {

        x=a;

        y=b;

    }

    void show1()

    {

        cout<<x<<" "<<y<<endl;

    }

    int get_x()

    {

        return x;

    }

    int get_y()

    {

        return y;

    }


};

class item

{

    int a,b;

   public:

    item(){}

    void show()

    {

        cout<<a<<" "<<b<<endl;

    }

    item(item1 it1)

    {

        a=it1.get_x();

        b=it1.get_y();


    }

};

int main()

{

    item1 it2(10,20);

    //it2.show1();

    item it3;

    it3=it2;

    it3.show();


    return 0;

}


Post a Comment

0 Comments