0

We haven't really covered pointers but have been learning about passing by reference (the & pointer will be covered later). In an exercise, we were asked to write a small question game that would pass values in a simple one class main program between its functions to get things done.

If we have a hierarchy where main calls 2 functions: function askNum, and function giveStats, with askNum having a host of functions inside (one on the lower level being checkIfRight). I need to call giveStats which would basically tell the user how well they've guessed over a set of questions.

I am glossing over the details because I want to focus on the fact that we can't use value returning functions or global variables. So I have to figure out a way to count the number of guesses correct within checkIfRight and send that info back up the hierarchy of functions to giveStats.

I am not sure how to call it though. I have most of the code figured out for this game and implemented simple pass by reference on functions in the same hierarchy, I am confused about having a function outside basically call it. So would there be a variable in main called numCorrect and giveStats would call it after askNum modifies it?

Sahib Yar
  • 1,030
  • 11
  • 29
mobcity zkore
  • 263
  • 1
  • 8
  • 5
    I guess if you present some code with the functions and what you are doing, then it will be easier to take it further. – macroland Aug 09 '17 at 04:17
  • 1
    Please post your question so that it can pass the criteria of [Minimal, Complete, and Verifiable](https://stackoverflow.com/help/mcve) as mentioned in the [help center](https://stackoverflow.com/help). – Sahib Yar Aug 09 '17 at 04:35
  • Narrow your question with a specific code sample. Vague descriptions are too broad, and are not a good fit for the SO format. – StoryTeller - Unslander Monica Aug 09 '17 at 05:01

0 Answers0