# include<iostream.h>
class Student
{
public:
char *name;
int rollNo;
int semNo;
public:
Student()
{
name=new char[20];
rollNo=0;
semNo=0;
}
Student(char *n,int r,int s)
{
name=new char[20];
name=n;
rollNo=r;
semNo=s;
}
void setName(char *n)
{
if(n!=NULL)
{
name=n;
}
}
char* getName()
{
return name;
}
void setRollNo(int r)
{
rollNo=r;
}
int getRollNo()
{
return rollNo;
}
};
void main()
{
Student obj;
Student obj1("pakistan",43,2);
cout<<obj1.getName()<<endl;
cout<<obj1.getRollNo()<<endl;
//cout<<obj1.ge
//obj.name="amir";
//cout<<*(&obj.name)<<endl;
//cout<<obj.name[2];
//obj.setName("amir");
//cout<<obj.getName();
}
class Student
{
public:
char *name;
int rollNo;
int semNo;
public:
Student()
{
name=new char[20];
rollNo=0;
semNo=0;
}
Student(char *n,int r,int s)
{
name=new char[20];
name=n;
rollNo=r;
semNo=s;
}
void setName(char *n)
{
if(n!=NULL)
{
name=n;
}
}
char* getName()
{
return name;
}
void setRollNo(int r)
{
rollNo=r;
}
int getRollNo()
{
return rollNo;
}
};
void main()
{
Student obj;
Student obj1("pakistan",43,2);
cout<<obj1.getName()<<endl;
cout<<obj1.getRollNo()<<endl;
//cout<<obj1.ge
//obj.name="amir";
//cout<<*(&obj.name)<<endl;
//cout<<obj.name[2];
//obj.setName("amir");
//cout<<obj.getName();
}
No comments:
Post a Comment