218k views
1 vote
Member fields and Constructors Student Test1(string last, string first, int idNo) For this test you will add member fields and constructors to the Student class. The private member fields to add are a string to represent a last name, a string to represent a first name and an int to represent an identification number. You will provide the default (no parameter) constructor and one overloaded constructor. - The default constructor will set last and first names to empty strings ("") and set the id number to 1000000 (1 million). - The overloaded constructor that will accept two strings (last name, first name) and one int (id number) and update the member fields the received values. After making the specified additions in the Student class, create and then return a new Student object using the provided parameters.

User Davejal
by
8.0k points

1 Answer

6 votes

Final answer:

To add member fields and constructors to the Student class, define the member fields, implement the default constructor and overloaded constructor, and create a new Student object.

Step-by-step explanation:

In this question, you are asked to add member fields and constructors to the Student class. The member fields are a string for the last name, a string for the first name, and an int for the identification number. You need to provide a default constructor that sets the last and first names to empty strings and the id number to 1 million. Additionally, you need to provide an overloaded constructor that accepts two strings (last name, first name) and one int (id number) and updates the member fields with the received values.

To solve this, you can define the member fields in the Student class and implement the default constructor and the overloaded constructor. In the default constructor, you can set the member fields to their default values. In the overloaded constructor, you can assign the received values to the member fields. Finally, you can create a new Student object using the provided parameters.

User Losnir
by
7.7k points