NBA - Boston Celtics

Monday 17 June 2013

HHW COTOR AND DTOR (1)


#include<conio.h>
#include<stdio.h>
#include<string.h>
class stud
{
int sno;
char sname[40];
public :
stud( )        // Default Constructor
{
sno=0;
strcpy(sname,"new");
cout<<"\nConstructing the object............";
}
~stud( )          // Destructor
{
cout<< "\nDestructing the object..............";
}
void getinfo( )
{
cout<<"\nEnter Student No. :";
cin>> sno;
cout<<"\nEnter Student Name :";
gets(sname);
}
void showinfo( )
{
cout<< "\n Student No.: "<<sno;
cout<<"\n Student Name :";
puts(sname);
}
};
void main()
{
clrscr();
stud obj;
obj.showinfo();
obj.getinfo();
obj.showinfo();
getch();
}

output


No comments:

Post a Comment