0% found this document useful (0 votes)
21 views

Exp6 1

This C++ program defines two classes, sy and ty, that each hold an integer variable. It includes a function to exchange the values of objects from each class. The main function gets input for two objects, calls the exchange function to swap their values, and then displays the new values, demonstrating that the exchange function successfully swapped the data between the two classes.

Uploaded by

sakharam_gawade
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Exp6 1

This C++ program defines two classes, sy and ty, that each hold an integer variable. It includes a function to exchange the values of objects from each class. The main function gets input for two objects, calls the exchange function to swap their values, and then displays the new values, demonstrating that the exchange function successfully swapped the data between the two classes.

Uploaded by

sakharam_gawade
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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

h> class ty; class sy { int var1; public: void getdata() { cin>>var1; } void putdata() { cout<<endl<<var1; } friend void xchng(sy&,ty&); }; class ty { int var2; public: void getdata() { cin>>var2; } void putdata() { cout<<endl<<var2; } friend void xchng(sy&,ty&); }; void xchng(sy&s,ty&t) { int temp; temp=s.var1; s.var1=t.var2; t.var2=temp; } void main() { clrscr(); sy s1; ty t1; cout<<"Enter any two numbers:\n"; s1.getdata(); t1.getdata(); xchng(s1,t1); cout<<"Values after swapping:\n"; s1.putdata(); t1.putdata(); getch(); }

Page 1

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)

You might also like