// This code illustrates when member functions should be const. // It won’t compile, as written. #include using namespace std; class Ratio { public: Ratio(int a, int b) : top(a), bottom(b) { } int get_top() { return top; } // Make this const to compile int get_bottom() { return bottom; } // Make this const to compile private: int top, bottom; }; int main() { const Ratio f(11,22); cout << f.get_top() << '\n'; return 0; }