Sunday, January 26, 2014

C++ Program using Class with Constructor

with 0 Comment
C++ Program using Class with Constructor:

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class integer
{
int m,n;
public:
integer(int,int);
void display(void)
{
cout<<"m="<<m<<"\n";
cout<<"n="<<n<<"\n";
}
};
integer::integer(int x,int y)
{
m=x;
n=y;
}
void main()
{
integer int1(0,100);
integer int2=integer(25,75);
clrscr();
cout<<"\n OBJECT 1"<<"\n";
int1.display();
cout<<"\n OBJECT 2"<<"\n";
int2.display();
getch();
}

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive