The "Big Five" Exercises |
< Previous Next > |
#include <iostream> #include <string> using std::string; using std::cout; class SimpleDoubleHolder{ public: // 1) Constructor (with optional argument) // 2) Include the "Big Five" here // 2a) // 2b) // 2c) // 2d) // 2e) void setDouble( double value); void printDouble(); private: double* m_DoublePtr; }; void SimpleDoubleHolder::printDouble(){ cout << "m_DoublePtr: "; if( m_DoublePtr == nullptr){ cout << "nullptr\n"; }else{ cout << *m_DoublePtr << "\n"; } } // setter for data member void SimpleDoubleHolder::setDouble( double value){ m_DoublePtr = new double( value); } // Constructor (with optional argument)
Last Modified: