Question
c++ modify code without condensing into one file to get string to work #include #include #include people.h using namespace std; /* classes */ int main()
c++ modify code without condensing into one file to get string to work
#include
int main() {
Person p1;
p1.set_age(31); p1.set_name("bob");
cout << "my age is " << p1.get_age() << endl; cout << "my name is " << p1.get_name(); return 0; }
----------------------------------------people.h
#ifndef PEOPLE_H_INCLUDED #define PEOPLE_H_INCLUDED
class Person { private : int age; string name; public : void set_age(int); int get_age(); void set_name(string); string get_name(); };
#endif // PEOPLE_H_INCLUDED
--------------------------------->people.cpp
#include "people.h" #include
using namespace std;
void Person ::set_age(int value) { age = value; }
int Person::get_age() { return age; }
void Person::set_name(string info) { name = info; }
string Person::get_name() { return name; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started