Thursday, February 4, 2016

Screen Capture of this program



#include <iostream>
#include<conio.h>

using namespace std;
class Y;
class X
    {
        int a;
        public:
        void Setvalues()
        {
            a=10;

        }
        friend void swap(X&,Y&);
        void display();
    };
    void X:: display()
    {

        cout<<"First Number="<<a<<endl;
    }

    class Y
    {
        int b;
        public:
        void Setvalues()
        {
            b=20;
        }
        friend void swap (X&,Y&);
        void display();
    };
    void Y:: display()
    {
        cout<<"Second Number="<<b<<endl;
    }

    void swap (X&x,Y&y)
    {
        int temp = x.a;
        x.a =y.b;
        y.b= temp;
    }
    int main()
    {
        X xobj;
        Y yobj;
        xobj.Setvalues();
        yobj.Setvalues();
        cout<<"Before Swaping"<<endl;
        xobj.display();
        yobj.display();
        cout<<"*********************"<<endl;
        cout<<"*********************"<<endl;
        cout<<"After Swaping"<<endl;
        swap(xobj,yobj);
        xobj.display();
        yobj.display();
        cout<<"!!!!!Thank you!!!!!"<<endl;

    getch();
    }

0 comments:

Post a Comment

Translate

Sample Text

Powered by Blogger.

Every thing is possible in real world....

Contact us

Name

Email *

Message *

IT Support

Blogroll

You can replace this text by going to "Layout" and then "Page Elements" section. Edit " About "

Video

Our Facebook Page

Popular Posts

Total Pageviews