I am attempting to create a Person class that has values: string name, int age, int height, int weight. I am supposed to instantiate a Person object, give it values, and output those values. Also, I am supposed to have a ModifyPerson function that accepts a Person object as argument, and change the name member variable and output it. Any help would be greatly appreciated.
EDIT: Only issue I currently have with code is properly outputting the member values of person1
EDIT2: Fixed! Thank you Zebrafish
#include <iostream>
#include <string>
using namespace std;
class Person
{
string name;
int age, height, weight;
public:
void set_values(string, int, int, int);
string ModifyPerson();
void coutDetails() const;
}person1;
void Person::set_values(string a, int b, int c, int d)
{
name = "Rob";
age = 19;
height = 71;
weight = 180;
}
string Person::ModifyPerson()
{
string name = "Robert";
return name;
}
void Person::coutDetails() const
{
cout << "\nName: " << name << "\nAge: " << age << "\nHeight: " <<
height << "\nWeight: " << weight;
}
std::ostream& operator<<(const std::ostream&, const Person& person1)
{
person1.coutDetails();
return std::cout;
}
int main()
{
Person person1;
person1.set_values("Rob", 19, 71, 180);
cout << person1 << endl;
cout << person1.ModifyPerson() << endl;
return 0;
}