C++: Create a Dynamic 2D Array Class. This class should overload the Call Operat
ID: 3588251 • Letter: C
Question
C++:
Create a Dynamic 2D Array Class. This class should overload the Call Operator () for the following behaviors:
Return (modifiable) Lvalue element for a non-const object
Return (read-only) Rvalue element for a const object
Return a copy of the data values for row
Return a copy of all the data as a 1D vector
Create a TestScores Class which uses a Dynamic 2D Array object as an internal data structure. This class should have the following behaviors:
Get the scores for a given student
Get the average score for a given student
Get the class average
Get the Standard Deviation for the class
Create a BandPassFilter which allow only scores within One-Sigma to pass through. Answer the questions:
How many scores passed through?
What percentage is this?
How does this compare to a Normal Distribution?
Demonstrate your classes with a TestScores Object which has 15 students with five(5) test scores each. Generate scores between 45 and 100 using a Random Generator.
Explanation / Answer
class Array2DWrapper { int *ptr; public: Array2DWrapper(int *ptr) : ptr(ptr) {} int * operator[](int i) { return ptr + i*N; } }; // USAGE: void exampleFunction(int *arrPtr) { Array2DWrapper arr { arrPtr }; ... arr[i][j]; ... } class Array2DWrapperDynamicN { int *ptr; int N; public: Array2DWrapper(int *ptr, int N) : ptr(ptr), N(N) {} int * operator[](int i) { return ptr + i*N; } }; class Array2DWrapperDynamicN { int *ptr; int N; public: Array2DWrapper(int *ptr, int N) : ptr(ptr), N(N) {} int * operator[](int i) { return ptr + i*N; } };
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.