Learning Goal: I’m working on a c++ exercise and need an explanation and answer
Learning Goal: I'm working on a c++ exercise and need an explanation and answer to help me learn. I need help with a cse lab. Only 1 lab, you will need to go into the school database. Lab Exercise Write C++ programs that: Define the class Student in the file Student.cpp. You are supposed to implement all the member functions including the constructors.#ifndef STUDENT_H #define STUDENT_H #include #include using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int idvalue, const string& namevalue) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student name. void set_name(const string& namevalue) { } // Sets the student id. void set_id(int idvalue) { } // Prints the student id and name. void print_student() const { } private: // student name string name; // student id int id; }; template struct NodeType { T data; NodeType* next; NodeType(): data(), next(nullptr) {} NodeType(const T& s): data(s), next(nullptr) {} }; #endif The main() function is contained in the file lab03.cpp. The main() function,Declares a pointer head which points to NodeType object. Prompts the user to enter a student information (id and name) and adds this newly created student object in the linked structure, stops adding the students when the user enters 0 as a student id. Displays all students in the linked structure. Prompts the user to enter the student id to be removed, and remove the student from the linked structure. Displays all students in the linked structure. Cleans the linked structure. The expected result: Enter the student id and name: 1101 Taylor The student is added Enter the student id and name: 1102 Smith The student is added Enter the student id and name: 1103 Alice The student is added Enter the student id and name: 1104 Tom The student is added Enter the student id and name: 0 no The students are: 1104 Tom 1103 Alice 1102 Smith 1101 Taylor The student id to be removed: 1102 The student is removed The students are: 1104 Tom 1103 Alice 1101 Taylor Compile This lab exercise should be put under cse2020/lab03 subdirectory. $g++ Student.cpp -c $g++ lab03.cpp -o lab03 $./lab03 ... $ script lab03log.txt ... Hand In Student.cpp: the header file. lab03.cpp: the test file containing main() funcion. lab03log.txt: the script file which captures the result.

Leave a Reply

Your email address will not be published. Required fields are marked *