Hi all, in my code below, I have 2 objects, each with "age" member data. I have a method that is supposed to add those ages and convert them to another number, but I don't know how to get the method to run. My full program has 4 objects that have to run this method on every other one, like:
the " + " being the method determinAge()
man1 + man1
man1 + man2
man1 + man3
man1 + man4
man2 + man2
etc
Ok,
Basically you are not using the passed tests in the test::determineAge() function.
Maybe you want to use:
On line 33: diff =guy1.age - guy2.age;
Thank you!
Magically, incredibly, that worked! But, I think I'm close, but still way off. I had the this-> in there because we were instructed to use this-> specifically. Having the objects in the test::determineAge() function might not be correct... Any idea on how to get test::determineAge() function to work using this-> ?
Definitely!
Here's how:
on line 13 write: double determineAge(test* guy1, test* guy2);
On line 26 write: cout << man1.determineAge(&man1, &man2) << endl;
Now, on line 33 you can use the -> operator like this:
line 33: diff =guy1->age - guy2->age;
Does this solve your problem?
To give you a decent answer we really need a clearer explanation of the problem.
To start with, the determineAge() function doesn't appear to determine an age. Only once it's clear what it's supposed to to will it possible to decide whether it is better as a member function or otherwise.
Both of you have been a huge help! You've answered the questions you thought I was asking and have answered questions I didn't know I had. You guys did a fantastic job of deciphering the question I didn't have the words to ask.