Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: C++ all instructions provided help needed and really appreciated Description: A simple Student Record that contains the minimum amount of information required for a

Language: C++
all instructions provided
help needed and really appreciated image text in transcribed
image text in transcribed
image text in transcribed
Description: A simple Student Record that contains the minimum amount of information required for a student at a learning institution. Instructions: The class definition Create the class definition for student with the following private attributes: Firstname: We are assuming that each student has a first name. When a Student object is created and there is no name, then provide both a default first name and last name that is rare enough not be be mistaken for a name, like "unknown" and "student". Lastname: We also assume the student has a last name. If the last name is not provided during construction, but the first name is, then assign the default last name. id: The id is a unique value between 1000 and 9999 in this assignment. The number is automatically assigned to each student and remains the unique identifier for that student. We will discuss how to implement this using a static variable during this week's lab. Inside the class definition, the following member functions must be added: Constructor(s): There are three ways for a user to create a Student object, so the class will have either three constructors or a single constructor that takes advantage of the default parameters in C++ function definitions. A working program that instantiates three Student objects: Student s1("Burns", "Nicky"); Student s2("Joan"); Student 53 ; will produce Student objects with the names: - 1000: Burns, Nicky - 1001: Joan, unknown - 1002: student, unknown In the above example, the default string "student" is assigned to lastname if it is not provided in the constructor call, while the default "unknown" is assigned to firstname if it is unavailable upon construction. You may choose to create three different (overloaded) constructors or you may use default parameters in a single constructor to implement this. Destructor: Because no dynamic memory is allocated in the construction of a Student object an experienced programmer will generally not create a destructor and rely on the on the default, which is that nothing happens. However, for this assignment, you are to create the destructor with a single command: -Student() \{cout "Destructor called n ; \} The purpose of this is to verify (and understand) what happens during runtime when an object goes out of scope. getters and setters: For each of the private member variables (attributes), create a get_var_name and a set_var_name function that communicates this information with the user. Write a short description above each of these member functions that explains why this function should allow the access it supplies. For instance, is it reasonable for a qualified user to access a student id?, would there be a condition under which a user can change a student's name? HINT There is one setter that would not be reasonable. If you know which one it is, then omit it. to-string: It is my recommendation that every class definition include a to-string member function*". Of course, every data type should also include a print to the console function, to help visualize during development and testing. However, a string representation has more versatility than printing to the console. The to-string member function returns a string that is formatted with infor-mation about the attributes. Something like Student: 1234 Lastname, Firstname is fine. friend bool operator = (Student\& s1, Student\& s2): Determining equality of two objects is a useful function for any class definition. C++ allows for standard operators to be overloaded, and most programmers are familiar with = to determine equality. For complex data types, we (the designers) must determine what makes two objects equivalent to each other. In this case, we assume they are equivalent if all of the attributes are equivalent. NOTE that for this assignment, there is no requirement to create the similar operator overload for the != operator but when we build professional class definitions, we should include it. friend bool operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago