- #1
ineedhelpnow
- 651
- 0
Print person1's kids, apply the IncNumKids() function, and print again, outputting text as below. End each line with newline.
Sample output for below program:
Kids: 3
New baby, kids now: 4
Sample program:
Below, do not type an entire program. Only type the portion indicated by the above instructions (and if a sample program is shown above, only type the <STUDENT CODE> portion.)
ok so i got this part so far which is correct according to the homework:
i can't figure out what will display the number afterwards. I am guessing it has to do with IncNumKids but i don't know what.
Sample output for below program:
Kids: 3
New baby, kids now: 4
Sample program:
Code:
#include <iostream>
using namespace std;
class PersonInfo {
public:
void SetNumKids(int personsKids);
void IncNumKids();
int GetNumKids() const;
private:
int numKids;
};
void PersonInfo::SetNumKids(int personsKids) {
numKids = personsKids;
return;
}
void PersonInfo::IncNumKids() {
numKids = numKids + 1;
return;
}
int PersonInfo::GetNumKids() const {
return numKids;
}
int main() {
PersonInfo person1;
person1.SetNumKids(3);
<STUDENT CODE>
return 0;
}
Below, do not type an entire program. Only type the portion indicated by the above instructions (and if a sample program is shown above, only type the <STUDENT CODE> portion.)
ok so i got this part so far which is correct according to the homework:
Code:
cout << "Kids: " <<person1.GetNumKids()<< endl;
PersonInfo IncNumKids;
cout << "New baby, kids now: " << I DONT KNOW WHAT TO PUT HERE<<endl;