Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please follow the instructions and make a program based on C++ language, and make a description for each code. Highlig // Student.h #ifndef STUDENT_H #define

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedPlease follow the instructions and make a program based on C++ language, and make a description for each code.

Highlig // Student.h #ifndef STUDENT_H #define STUDENT_H #include class Student { private: std::string name; std::string id; std::string phoneNumber; int age; char gender; std::string standing; double gpa; public: Student(); Student(std::string name, std::string id, std::string phoneNumber, int age, char gender, std::string standing, double gpa); void setName(std::string name); void setID(std::string id); void setPhoneNumber(std::string phoneNumber); void setAge(int age); void setGender(char gender); void setStanding(std::string standing); void setGPA( double gpa); virtual void print() const; }; class Date { private: int day, month, year; public: Date(); Date(int day, int month, int year); void setDay(int day); void setMonth(int month); void setYear(int year); void print() const; }; class CS1CStudent : public Student { private: int total_score; bool knows_python; Date graduation_date; public: CSICStudent(); csicStudent(std::string name, std::string id, std::string phoneNumber, int age, char gender, std::string standing, double gpa, int total score, bool knows python, Date graduation_date); void setTotalScore(int total score); void knowsPython(bool knows_python); void setGraduationDate(Date graduation_date); void print() const; }; #endif // STUDENT_H 7/end of Student.h 1/ Student.cpp #include "Student.h" #include #include using namespace std; // Student default constructor Student::Student(): name("No name"), id("NO ID"), phoneNumber("Not Set"), age(), gender("N'), standing("Not Set"), gpa() O Student parameterized constructor Student::Student(std::string name, std::string id, std::string phoneNumber, int age, char gender, std::string standing, double gpa) name (name), id(id), phoneNumber(phoneNumber), age (age), gender(gender), standing(standing), gpa(gpa) // Student setters void Student::setName(std::string name) { this->name name; } void Student::setID(std::string id) { this->id = id; } void Student::setPhoneNumber(std::string phoneNumber) { this->phoneNumber phoneNumber; void Student::setAge(int age) { this->age = age; } void Student::setGender(char gender) { this->gender = gender; } void Student::setStanding(std::string standing) { this->standing standings void Student::setGPA( double gpa) { this->gpa - Epa; } 1/ Student print function to display all the fields of the Student void Student::print() const { cout day = day; } void Date::setMonth(int month) { this->month month; } void Date::setYear(int year) { this->year year, 11 Date print function to display all the fields of date void Date: :print() const cout total_score = total score; this->total_score = total score; } void CSI Student :: knowsPython(hool knows.python) { this->knows_python = knows_python; void csicStudent::setGraduationDate(Date graduation date) { this->graduation_date = graduation date; } 11 overriden print function void CS1CStudent::print() const { Student::print(); // calls base class Student print function // displays the additional fields of CsicStudent cout #include #include "Student.h" using namespace std; int main() { // test Student class Student students() { Student(), Student("Madonna","123456", "714-555-5555", 61, 'F', "Sophomore", 3.23) Student(), Student("Lady Gaga","777744", "213-555-6789", 33, "F", "Freshman", 2.10) }; const int num_students = 4; cout Options- >Debugging->Automatically close the console when debugging stops. Press any key to close this window Assignment 4 1. Using Assignment #2, derive a Software Developer class from the Student class. Add the following data members to the a Software Developer class: a. A character pointer for the Software Developer's address (e.g. char * address) b. A character pointer for the SoftwareDeveloper's city A character pointer for the Software Developer's state d. A zip code 2. Write and test change address, city, state, and zip code member functions for the Software Developer class. 3. Write a copy constructor for the Software Developer class. 4. Write a deep copy member function for the Software Developer class, 5. Change the print Software Developer function to display all its data members. 6. Change the age and city of a Software Developer. Test your change methods. Note: (a) Your constructors for the Software Developer class that have parameters should use dynamic memory and (b) you will have to write a destructor that frees dynamic memory Test your program by Adding a cout statement to your copy constructor, constructors, and destructors. Print out the number of each step 1. Write a function that passes by copy (the copy constructor should be called) Assignment 4 2. Write a function that passes by reference 3. Write a function that returns by copy (the copy constructor should be called) 4. Write a function that returns by reference (the copy constructor should not be called) 5. Use the initialization construct (the copy constructor should be called) 6. Test your deep copy function DO NOT include your Assignment #2 output in Assignment #4 Software Developers Nume Students Phone Age CAPA Joe Calculus Mary Alec Jo Trg 64879 76309 10192 949.555.1210 211.555.5555 214-703.1234 Gender Cle Stinin M Finan F Junior F Schio 21 28 Nams Addres Joe Calculus 1214 Main Avenue Mary 3313 Marguerite lkwy Alebra Jo Trig 9876 Elm Street Caly Laruna Niguel Miss Vieja State CA CA Zip Code 92671 92646 San Clemente CA 92672 Highlig // Student.h #ifndef STUDENT_H #define STUDENT_H #include class Student { private: std::string name; std::string id; std::string phoneNumber; int age; char gender; std::string standing; double gpa; public: Student(); Student(std::string name, std::string id, std::string phoneNumber, int age, char gender, std::string standing, double gpa); void setName(std::string name); void setID(std::string id); void setPhoneNumber(std::string phoneNumber); void setAge(int age); void setGender(char gender); void setStanding(std::string standing); void setGPA( double gpa); virtual void print() const; }; class Date { private: int day, month, year; public: Date(); Date(int day, int month, int year); void setDay(int day); void setMonth(int month); void setYear(int year); void print() const; }; class CS1CStudent : public Student { private: int total_score; bool knows_python; Date graduation_date; public: CSICStudent(); csicStudent(std::string name, std::string id, std::string phoneNumber, int age, char gender, std::string standing, double gpa, int total score, bool knows python, Date graduation_date); void setTotalScore(int total score); void knowsPython(bool knows_python); void setGraduationDate(Date graduation_date); void print() const; }; #endif // STUDENT_H 7/end of Student.h 1/ Student.cpp #include "Student.h" #include #include using namespace std; // Student default constructor Student::Student(): name("No name"), id("NO ID"), phoneNumber("Not Set"), age(), gender("N'), standing("Not Set"), gpa() O Student parameterized constructor Student::Student(std::string name, std::string id, std::string phoneNumber, int age, char gender, std::string standing, double gpa) name (name), id(id), phoneNumber(phoneNumber), age (age), gender(gender), standing(standing), gpa(gpa) // Student setters void Student::setName(std::string name) { this->name name; } void Student::setID(std::string id) { this->id = id; } void Student::setPhoneNumber(std::string phoneNumber) { this->phoneNumber phoneNumber; void Student::setAge(int age) { this->age = age; } void Student::setGender(char gender) { this->gender = gender; } void Student::setStanding(std::string standing) { this->standing standings void Student::setGPA( double gpa) { this->gpa - Epa; } 1/ Student print function to display all the fields of the Student void Student::print() const { cout day = day; } void Date::setMonth(int month) { this->month month; } void Date::setYear(int year) { this->year year, 11 Date print function to display all the fields of date void Date: :print() const cout total_score = total score; this->total_score = total score; } void CSI Student :: knowsPython(hool knows.python) { this->knows_python = knows_python; void csicStudent::setGraduationDate(Date graduation date) { this->graduation_date = graduation date; } 11 overriden print function void CS1CStudent::print() const { Student::print(); // calls base class Student print function // displays the additional fields of CsicStudent cout #include #include "Student.h" using namespace std; int main() { // test Student class Student students() { Student(), Student("Madonna","123456", "714-555-5555", 61, 'F', "Sophomore", 3.23) Student(), Student("Lady Gaga","777744", "213-555-6789", 33, "F", "Freshman", 2.10) }; const int num_students = 4; cout Options- >Debugging->Automatically close the console when debugging stops. Press any key to close this window Assignment 4 1. Using Assignment #2, derive a Software Developer class from the Student class. Add the following data members to the a Software Developer class: a. A character pointer for the Software Developer's address (e.g. char * address) b. A character pointer for the SoftwareDeveloper's city A character pointer for the Software Developer's state d. A zip code 2. Write and test change address, city, state, and zip code member functions for the Software Developer class. 3. Write a copy constructor for the Software Developer class. 4. Write a deep copy member function for the Software Developer class, 5. Change the print Software Developer function to display all its data members. 6. Change the age and city of a Software Developer. Test your change methods. Note: (a) Your constructors for the Software Developer class that have parameters should use dynamic memory and (b) you will have to write a destructor that frees dynamic memory Test your program by Adding a cout statement to your copy constructor, constructors, and destructors. Print out the number of each step 1. Write a function that passes by copy (the copy constructor should be called) Assignment 4 2. Write a function that passes by reference 3. Write a function that returns by copy (the copy constructor should be called) 4. Write a function that returns by reference (the copy constructor should not be called) 5. Use the initialization construct (the copy constructor should be called) 6. Test your deep copy function DO NOT include your Assignment #2 output in Assignment #4 Software Developers Nume Students Phone Age CAPA Joe Calculus Mary Alec Jo Trg 64879 76309 10192 949.555.1210 211.555.5555 214-703.1234 Gender Cle Stinin M Finan F Junior F Schio 21 28 Nams Addres Joe Calculus 1214 Main Avenue Mary 3313 Marguerite lkwy Alebra Jo Trig 9876 Elm Street Caly Laruna Niguel Miss Vieja State CA CA Zip Code 92671 92646 San Clemente CA 92672

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

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions