Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please make a code based on the instruction and based on the code. Make a code in C++, and make descriptions for each code. //

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedPlease make a code based on the instruction and based on the code. Make a code in C++, and make descriptions for each code.

// 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: CS1CStudent(); CS1CStudent(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 //end of Student.h // 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(0), gender('N'), standing("Not Set"), gpa(0) {} // 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 = standing; } void Student::setGPA(double gpa) { this->gpa = gpa; } // 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; } // Date print function to display all the fields of date void Date::print() const { cout total_score = total_score; } void CS1CStudent::knowsPython(bool knows_python) { this->knows_python = knows_python; } void CS1CStudent::setGraduationDate(Date graduation_date) { this->graduation_date = graduation_date; } // overriden print function void CS1CStudent::print() const { Student::print(); // calls base class Student print function // displays the additional fields of CS1CStudent 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 Software Developer's city C. 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 SoftwareDeveloper class. 3. Write a copy constructor for the SoftwareDeveloper 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 Name Phone Age GIA Joc Calculus Mary Algebra Jo Trig Student's la 64879 76309 10192 949-555.1234 213-555-5555 714-703-1234 44 21 28 Gender Class Standing M Freshman F Junior I Senior 3.3 4.0 29 State Name Joe Calculus Mary Algebra Jo Trig Address 1234 Main Avenue 3333 Marguerite Pkwy City Laguna Niguel Mission Viejo Zip Code 92677 92646 CA 9876 Elm Street San Clemente CA 92672 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 Software Developer's city C. 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 SoftwareDeveloper class. 3. Write a copy constructor for the SoftwareDeveloper 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 Name Phone Age GIA Joc Calculus Mary Algebra Jo Trig Student's la 64879 76309 10192 949-555.1234 213-555-5555 714-703-1234 44 21 28 Gender Class Standing M Freshman F Junior I Senior 3.3 4.0 29 State Name Joe Calculus Mary Algebra Jo Trig Address 1234 Main Avenue 3333 Marguerite Pkwy City Laguna Niguel Mission Viejo Zip Code 92677 92646 CA 9876 Elm Street 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

Step: 3

blur-text-image

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions