Define a class student in C++ with the following description. a) data member roll number, name, score, and remarks b) member function to allow user (i) to enter the details (ii) to view the contents of all the data members
#include<iostream>
using namespace std;
class student{
private:
int roll_number;
string name;
double score;
string remarks;
public:
void accept(){
cout<<"Enter student roll number: \n";
cin>>roll_number;
cout<<"Enter the student name:\n";
cin>>name;
cout<<"Enter student score:\n";
cin>>score;
cout<<"Enter student remarks:\n";
cin>>remarks;
}
void display(){
cout<<"Roll number: "<<roll_number<<endl;
cout<<"Name: "<<name<<endl;
cout<<"Score: "<<score<<endl;
cout<<"Remark: "<<remarks<<endl;
}
};
int main(){
student st;
st.accept();
st.display();
}
Comments
Leave a comment