c++ Implement a MyInt class. An object in the MyInt class must be able to hold a single dynamically allocated integer. MyInt should have the following members: A member variable ptr of type int *. A parameterized constructor that takes nums of type int as input parameters. A destructor. A superimposed assignment operator (). The copy must be deep. A function set that sets the value of the number. A function get that returns the value of the number. The members must be encapsulated in accordance with the convention. Memory leaks must be avoided.
c++
Implement a MyInt class. An object in the MyInt class must be able to hold a single dynamically allocated integer.
MyInt should have the following members:
A member variable ptr of type int *.
A parameterized constructor that takes nums of type int as input parameters.
A destructor.
A superimposed assignment operator (). The copy must be deep.
A function set that sets the value of the number.
A function get that returns the value of the number.
The members must be encapsulated in accordance with the convention. Memory leaks must be avoided.
To test your class, create objects and call functions according to the comments below. All tests must be validated.
Input Expected output
5 11 27 5 11 27
1 2 3 1 2 3
19 21 30 19 21 30
Step by step
Solved in 4 steps with 2 images