How to send class method to the screen

I cut out most of the code to keep this short. I need to cout:

 
  double test::determineAverage(test guy)


from:

 
  void test::display()


by a class object in main. I can display my objects, but I don't know how to call determineAverage() in display(). **How do I call determineAverage() in/from display()?

Here's much limited code for context:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class test
{
private:
   double age1, age2;

int main(void)
{
   test man1, man2;

   man1.setAge1(19);
   man2.setAge1(27);

   man1.display();
   man2.display();

   return 0;
}

double test::determineAverage(test guy)
{
   double fit; 

   //do stuff
   
   return fit;
}

void test::display()
{
   //How do i:
   cout << determineAverage()
}
Last edited on
I'm not sure I completely understand what you're going for here, but couldn't you just do this in main() on line 10:

man1.display(man2);

then have your display function look like this

void test::display(test guy) { cout << determineAverage(guy); }

If this isn't what you're looking for you'll have to give more information.
I apologize for not explaining more succinctly, it stems from my lack of knowledge. However, you answered my question and I thank you greatly!
OP,
You never, ever, define int main() inside of a class. Maybe that was because you deleted code to make it simpler. However, it was not clear to any people who try to help you.
Topic archived. No new replies allowed.