Aim: Write a
program to show the use of parameterized and with no
argument
constructor?
Ans:
#include<conio.h>
#include<iostream.h>
#include<string.h>
class student
{
int rollno;
char branch[20],name[20];
public:
student()
{
clrscr();
cout<<"Enter
rollno , branch, name\n";
cin>>rollno>>branch>>name;
cout<<rollno<<"
"<<branch<<" "<<name;
getch();
}
student(int
x,char *y,char *z)
{
rollno=x;
strcpy(branch,y);
strcpy(name,z);
cout<<"\n"<<rollno<<"
"<<branch<<" "<<name;
getch();
}
}m,n(56,"cse","abc");
void main()
{
}
No comments:
Post a Comment