Untitled
unknown
plain_text
a year ago
1.0 kB
8
Indexable
Never
#include <iostream> using namespace std; // Question:: class name "student" + constructor and destructor + 3 student records + inline function class student { string name; float marks; public: student() {} // I am Mr Constructor void info(string name, float marks) { this->name = name; this->marks = marks; } void display(int i); // I am Mr Inline ~student() {} // I am Mr Destructor }; // member function defination inline void student::display(int i) { cout << i + 1 << " :: " << name << " :: " << marks << endl; } // driver code int main() { student stud[3]; // Array of 3 students // Taking inputs for that 3 students for (int i = 0; i < 3; i++) { string name; float marks; cout << "Enter the name of student " << i + 1 << " : "; cin >> name; cout << "Enter the marks of student " << i + 1 << " : "; cin >> marks; stud[i].info(name, marks); } // To display student records for (int i = 0; i < 3; i++) { stud[i].display(i); } return 0; }