/************************************* Conversion Constructor Examples **************************************/ #include "Auto.h" #include using namespace std; class CExample { public: CExample(); CExample(int i); bool Compare(const CExample& e) const; private: int m_i; }; CExample::CExample() { m_i = 0; } CExample::CExample(int new_i) { m_i = new_i; } bool CExample::Compare(const CExample& e)const { bool Result = false; if (e.m_i == m_i) { Result = true; } return Result; } void main() { CExample example1; CExample example2(9); //normal use of the compare member funciton if (example1.Compare(example2)) { cout << "example1 and two are equal" << endl; } else { cout << "example1 and two are different" << endl; } //use of the compare member funciton by using the conversion constructor int AnyInteger = 0; if (example1.Compare(AnyInteger)) { cout << "example1 and two are equal" << endl; } else { cout << "example1 and two are different" << endl; } }