In the following program we define a class student with the the default constructor and a constructor function with argument
#include<iostream.h>
class studen{
private:
int rlno;
float mark;
public:
student(){}
Student(int,r,float m)
{
rlno=r;
mark=m;
}
void put()
{
cout<<"Rino="<<rlno;
cout<<"Mark="<<mark;
}
};
void main()
{
student s;
student K(120,78);
K.put();
getch();
}
Output:
Rino=120 Mark=78
No comments:
Post a Comment