Pages

Sunday, May 18, 2025

Object-Oriented Programming: Creating a Student Class from Person Base Class (Assignment Question 3)

 #include <iostream>

using namespace std;

class Person {
public:

    string name; // mistakes -> char name();
    int age; // mistakes -> int age();
};

class Student : public Person {
public:
     void displayStudentInfo(string id) {
        cout << "(" << name << "\", " << age << " ,\"" << id << "\")";  // in order to put double quotations please put \ then " so-> \" this is how it will work
        }
       
};



int main() {
    Student student;
    student.name = "\"Deb";
    student.age = 17;
    student.displayStudentInfo("S12345");

    return 0;
}

OUTPUT:
("Deb", 17 ,"S12345")

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...