Question
#define _CRT_SECURE_NO_WARNINGS #include using namespace std; class MyInt { int *m_data; public: MyInt(int val){ m_data = new int(val); } ~MyInt() { cout < < deleting:
#define _CRT_SECURE_NO_WARNINGS #include using namespace std;
class MyInt { int *m_data; public: MyInt(int val){ m_data = new int(val); } ~MyInt() { cout << "deleting: " << *m_data << endl; delete m_data; } // Create an assignment operator to set one MyInt to another // and return a reference of the current object
MyInt& operator = ( const MyInt &myint) {
m_data = myint.m_data; if (&myint !=this) { this.m_data = myint.m_data } return *this;
}
// Create an assignment operator to set one MyInt to another // and return a reference of the current object
how do i do this part? i attempted it below..
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started