Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the PrintAll() member function and a separate cout statement to output courseStudents's data. End with a newline. Sample output from the given program:Name: Smith, Age: 20, ID: 9999 #include #include using namespace std; class Person { public: void SetName(string userName) { lastName = userName; } void SetAge(int numYears) { ageYears = numYears; } // Other parts omitted void PrintAll() { cout << "Name: " << lastName; cout << ", Age: " << ageYears; } private: int ageYears; string lastName; }; class Student: public Person { public: void SetID(int studentId) { idNum = studentId; } int GetID() { return idNum; } private: int idNum; }; int main() { Student courseStudent; /* Your solution goes here */ return 0; }
Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the PrintAll() member function and a separate cout statement to output courseStudents's data. End with a newline. Sample output from the given program:Name: Smith, Age: 20, ID: 9999
#include <iostream>
#include <string>
using namespace std;
class Person {
public:
void SetName(string userName) {
lastName = userName;
}
void SetAge(int numYears) {
ageYears = numYears;
}
// Other parts omitted
void PrintAll() {
cout << "Name: " << lastName;
cout << ", Age: " << ageYears;
}
private:
int ageYears;
string lastName;
};
class Student: public Person {
public:
void SetID(int studentId) {
idNum = studentId;
}
int GetID() {
return idNum;
}
private:
int idNum;
};
int main() {
Student courseStudent;
/* Your solution goes here */
return 0;
}

Step by step
Solved in 3 steps with 1 images









