C++: Create a Dynamic 2D Array Class. This class should overload the Call Operat
ID: 3587966 • 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
#include #include #include class Cpu { public: virtual int dummy( int, int ) {} private: virtual int add_( int a, int b ) { return a + b; } /* A */ virtual int sub_( int a, int b ) { return a - b; } /* B */ virtual int mul_( int a, int b ) { return a * b; } /* C */ virtual int div_( int a, int b ) { return a / b; } /* D */ virtual int mod_( int a, int b ) { return a % b; } /* E */ virtual int and_( int a, int b ) { return a & b; } /* F */ virtual int or_( int a, int b ) { return a | b; } /* G */ virtual int xor_( int a, int b ) { return a ^ b; } /* H */ }; int main( int argc, char* argv[] ) { typedef int (Cpu::*Memfun)( int, int ); union { Memfun fn; unsigned char ptr[6]; } u; Cpu cpu; u.fn = &Cpu::dummy; assert( argc == 4 ); int p1 = atoi( argv[ 1 ] ); int p2 = atoi( argv[ 3 ] ); char op = argv[2][0]; assert( op >= 'A' && opRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.