Question: Declare and define a class Person in C++ syntax to model the given item - a person with the following features: Define the private portion
Declare and define a class Person in C++ syntax to model the given item - a person with the following features:
Define the private portion of the class Person for people consisting of an integer for ID and a char pointer to a dynamic array for name.
Define functions below to the Person class and implement these functions: Person(); // default constructor for a person named "Anonymous" and ID is 123456789 Person(char name[], int id); // constructor to initialize the name and ID int get_id() const; // accessor to retrieve student's ID void set_name(char new_name[]); // mutator to set or change student's name overload output operator << to print the Person infomation in the format: Person's name (Person's ID), e.g. Anonymous (987654321)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
