Question: Hello, i am in a c++ class and i am suppose to create a class that contains pointers. Can someone please help. Thank You !!!
Objective: To learn to handle pointer variables and use dynamic arrays to manipulate data in a class. Tasks In this programming assignment, you will write a program that defines a class called Student whose objects can have a flexible number of scores. The program prompts the user for the following information: first name and last name of a student, the maximum number of scores, and the actual scores of a student. For example, a student may have a maximum of 10 scores but actually input 5 scores. After all the scores are entered, the program calculates the student average score. The program should output student's information including a student's first name and last name, the actual number of scores, a list of all the scores, and the average score. A sample output (partial) is shown in Figure 1 Your program should define a class Student and implement it as required. The class Student should have the following private member variables. Member Variable 1 firstName 2 lastName Description A string variable that holds a student's first name. A string variable that holds a student's last name. An int variable that An int variable that represents the actual number of scores entered for a student. A pointer variable of type int that stores the address of an int dynamic array. The dynamic array is to store the student scores. 3 maxSize 4 size the maximum number of scores. 5 scores The class Student should also have the following public member functions. Member Function 1 A constructor with default parameters Description This constructor has three formal parameters and use them to initialize firstName, lastName, and maxSize member variables. The default values are empty string for firstName and lastName, and 10 for maxSize The value for maxSize should be positive, otherwise use 10 instead. The constructor also initializes size to 0 and creates a dynamic array of size maxSize whose address is stored in the pointer variable scores Accepts a string argument and copies it into the firstName member variable. Accepts a string argument and copies it into the lastName member variable. Returns the value in firstName 2 setFName 3 setLName 4 getFName
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
