A const exercise

Review the following code and determine where the keyword const is missing. Pay particular attention to class methods, parameters and return types.

Rewrite the code to include proper use of const, parameter passing and return types

#include <string> using namespace std; class Person { public: Person( string name, int age ); string GetName( ); int GetAge( ); void HappyBirthday( ); private: string m_name; int m_age; }; #include <iostream> #include "Person.h" using namespace std; Person::Person( string name, int age ) { m_name = name; m_age = age; } string Person::GetName( ) { return m_name; } int Person::GetAge( ) { return m_age; } void Person::HappyBirthday( ) { cout << "Happy Birthday " << m_name << endl; ++m_age; }


Last Modified: Monday, 28-Aug-2006 10:15:53 EDT