student information by inheritance opp c++;
#include<bits/stdc++.h>
using namespace std;
class person
{
public :
float mark;
string name;
void readname(string n)
{
name=n;
}
void readmark(float m)
{
mark=m;
}
};
class student : public person
{
public :
int id;
void readid(int i)
{
id=i;
}
void diplay()
{
cout<<"name : "<<name<<endl;
cout<<"ID : "<<id<<endl;
cout<<"Mark : "<<mark<<endl;
}
};
int main()
{
student s1;
s1.readname("Ujjal Roy");
s1.readid(20020);
s1.readmark(90.5);
s1.diplay();
return 0;
}
0 Comments