Code:
#include <iostream>
#include <string>
using namespace std;
class HeartBeats {
public:
explicit HeartBeats(string first, string last, int how_old)
: firstNam(first), lastNam(last), age(how_old)
{
}
void firstName(string first)
{
first=firstNam;
}
void lastName(string last)
{
last=lastNam;
}
void Age(string how_old)
{
how_old=age;
}
string get_First() const
{
return firstNam;
}
string getLastName() const
{
return lastNam;
}
int getAge() const
{
return age;
}
void CalculateBPM()
{
int BPM;
BPM = 220-age;
cout<<"Hello" <<firstNam<<", Your max Heart Rate should not be over"<<BPM<<"BPM"<<endl;
}
private:
string firstNam;
string lastNam;
int age;
};
int main(int argc, const char * argv[])
{
string firstname,lastname;
int PersonsAge;
cout<<"Enter the persons first name"<<endl;
getline(cin, firstname);
cout<<"Enter the persons last name"<<endl;
getline(cin, lastname);
cout<<"Enter the persons age"<<endl;
cin << PersonsAge;
HeartBeats heartBeats(firstname ,lastname, PersonsAge);
cout<< heartBeats.get_First()<<endl;
cout<< heartBeats.getLastName()<<endl;
cout<< heartBeats.getAge()<<endl;
cout<< heartBeats.CalculateBPM()<<endl;
return 0;
}
I the int PersonAge is not being sent to the class. Everything up to that point was fine.
I want to separate everything into .cpp file and .h files once I see it all working in one program. cin is simply giving me an error and the syntax is correct, what the heck?