Skip to content
#include<iostream.h>
#include<conio.h>
class num
{
int a;
public:
void swap(int&x,int&y)
{
a=y;
y=x;
x=a;
}
};
int main()
{
clrscr();
int a,b;
cout<<"Enter the number a and b :";
cin>>a>>b;
cout<<"\na="<<a<<"\nb="<<b;
num n;
n.swap(a,b);
cout<<"\na and b swaped \na="<<a<<"\nb="<<b;
getch();
return 0;
}
Class diagram
(click image to view large)
Related Posts: C++ Program to implement scaling in graphics
A scaling can be represented by a scaling matrix. To scale an object by a vector v = (vx, vy, vz), each point p = (px, py, … Read More C++ program to implement shearing in graphics
A shear is a transformation that distorts the shape of an object along either or both of the axies. Like scale and translate, a shear can be done alo… Read More C++ Program to implement Bresenham's circle algorithm (Graphics)
In computer graphics, the midpoint circle algorithm is an algorithm used to determine the points needed for drawing a circle. Bresenha… Read More C++ Program to draw umbralla couple (Simple Graphics)
#include <iostream.h>
#include <conio.h>
#include <graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"… Read More C++ Program to draw a bird with nest (Simple graphics)
#include <iostream.h>
#include <conio.h>
#include <graphics.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\Tc\… Read More
0 comments:
Post a Comment