Hi, I was wondering if someone could look at this person class I am working on. The first part is the class header with the constructors for the class. In the second part I am trying to write the code but when I declare the get_age and get_name objects I get an error that states --- declaration is incompatible with "std::string person::get_name() const" I get the same error for the get_age. Can someone help to explain to me what I am doing wrong? Thank YOU, C.D.
#ifndef Lab10
#define Lab10
#include <string>
using namespace std ;
class person
{
public:
person() ;
person( string pname, int page ) ;
string get_name() const ;
int get_age() const ;
private:
string name ;
int age ;
} ;
#endif
#include "Lab10.h"
#include <iostream>
#include <string>
person :: person()
{
int page = 0 ;
}
void person :: get_name() // This is where the error is !!!!!!!!!!!!!!
{
cout << "Please enter the name of the person ";
getline(cin,name) ;
}
int person :: get_age() // This is where the error is !!!!!!!!!!!!!!!
{
cout << "Please enter the age of the person " ;
cin >> age ;
return age ;
}