Tuesday 24 February 2015

Class Sample Program Using C++

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

class Rectangle
{
private:
int width,height;
public:
void Create(int w,int h)
{
width=w;
height=h;
}
void Display()
{
cout<<"\n Width :"<<width;
cout<<"\n Height :"<<height;
}
};
void display();
void main()
{
Rectangle r1,r2;
r1.Create(100,100);
r1.Display();
r2.Create(200,200);
r2.Display();
display();
}
void display()
{
cout<<"\n Welcome to Function";
}

No comments:

Post a Comment