Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Write a C++ program that includes the following . Define the class Student in the header file Student.h #1fndef STUDENTH #define STUDENTH #include #include using

image text in transcribed

image text in transcribed

image text in transcribed

Write a C++ program that includes the following . Define the class Student in the header file Student.h #1fndef STUDENTH #define STUDENTH #include #include using namespace std; - - class Student public: // Default constructor Student(); // Creates a student with the specified id and name Student(int id, const string& name); // Returns the student name string get_name() const; // Returns the student id. int get_student_id () const; // Sets the student name void set_name(const string& name); // Sets the student id. void set_student_id(int id); // Prints the student id and name. void print_student () const; private: / student name string name; // student id int id; d; #end if Impletment the class Student in the file Student.cpp .The main function is contained in the file lab01.cpp. The main function, 1. Prompts the user to enter a capacity, and then declares a pointer students pointing to a dynamic array of Student with the entered capacity 2. Prompts the user to enter a student's id and name. If the id is not 0, creates an object student1 with the entered id and name values. 3. Puts the object student1 in the dynamic array students. You may declare an int variable size to count the number of students stored in the dynamic array. 4. Repeats the step 2 and 3 until the entered student id is 0 5. Displays the information of students, that is, print out the student name and id in the dynamic array. The expected result Enter the dynamic array capacity: 10 Enter the student id: 1101 Enter the student name: Taylor Enter the student id: 1102 Enter the student name: Smith Enter the student id: 1103 Enter the student name: Alice Enter the student id: 1104 Enter the student name: Tom Enter the student id : The students are: 1101 Taylor 1182 Smith 1103 Alice 1104 Tom Compile This lab exercise should be put under cse330/1abe1 subdirectory Sg++ -c Student.cpp $.g++ -c label.cpp $g++ Student.o lab01.o -o labe1 $ls lab01.cpp lab01.o lab01 Student.cpp $./lab01 Student.h Student.o Capture the result in a script file lab@1result. $script lab01result $./lab01 exit $ls lab01.cpp lab01.o lab01 labelresult Student.cpp Student.h Student.o Handin Student.h: the header file containing attributes and member function prototypes with comments * Student.cpp: the implementation file containing the implementation of all member functions. lab01.cpp: the client test file containing main() funcion. lab01result: the script file which captures the result

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions