Creat a class student consisting of data members register number, bame, gender, fees and age of the students and creat member function to read and display the student information
#include <iostream>
#include <string>
class Student {
private:
std::string registerNumber;
std::string name;
std::string gender;
int fees = 0;
int age = 0;
public:
void read();
void display();
};
void Student::read() {
std::cout << "Enter information about student" << std::endl;
std::cout << "Register number: ";
std::cin >> registerNumber;
std::cout << "Name: ";
std::cin >> name;
std::cout << "Gender: ";
std::cin >> gender;
std::cout << "Fees: ";
std::cin >> fees;
std::cout << "Age: ";
std::cin >> age;
}
void Student::display() {
std::cout << "Student information" << std::endl;
std::cout << "Register number: " << registerNumber << std::endl;
std::cout << "Name: " << name << std::endl;
std::cout << "Gender: " << gender << std::endl;
std::cout << "Fees: " << fees << std::endl;
std::cout << "Age: " << age << std::endl;
}
int main() {
Student student;
student.read();
std::cout << std::endl;
student.display();
return 0;
}
Comments
Leave a comment