// pointers04.cpp #include class Maximum { public: Maximum() :m_p(0) {} // change pointer to specified variable, if the value is larger bool Evaluate(int& value) { if (!m_p || *m_p < value) { m_p = &value; return true; } return false; } // retrieve a pointer to the maximum value int* GetMaximum() { return m_p; } private: int* m_p; }; int main() { int a = 1, b = 3, c = 2; Maximum m; m.Evaluate(a); m.Evaluate(b); m.Evaluate(c); std::cout << "Maximum of a, b and c: " << *m.GetMaximum() << std::endl; *m.GetMaximum() -= 3; std::cout << "The value of b is " << b; return 0; }