Calling a function from within a Function???

Hey guys. So my teacher asked us to create 4 different Functions use in a Rock. Paper, Scissors game. getPlayerTurn, doComputerTurn, showOutcome, and playGame.

I was finally able to get the first 3 functions to run and compile, but I'm having trouble incorporating them into the "playGame" function. It compiles just fine, but when I run it nothing happens and I just see a blank line.

I'm not even sure if what I'm trying to get it to do is feasible. Can you have a function that calls three other functions inside it?

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
using namespace std;  

//Prototype declarations
void playGame();
int getPlayerTurn ();
int doComputerTurn ();
void showOutcome (int, int);

// The main function
int main () {
void playGame();
            }

//
// playGame
//    Plays one game until it is resolved.
//
// Parameters:
//    There are no parameters for this function.
//
// Return:
//    This function does not have a return value.
//
void playGame(){
   int choice = getPlayerTurn();
   int comp = doComputerTurn();
   showOutcome(choice, comp);
               }
//
// getPlayerTurn
//    Reads in the players choice and displays what they chose.
//
// Parameters:
//    There are no parameters for this function.
//
// Returns:
//    Returns the players choice.
//
int getPlayerTurn (){
   int choice;
   cout << "************ Rock, Paper, Scissors ************ \n";
   cout << "Enter 1 for Rock, 2 for Paper, 3 for Scissors: ";
   cin >> choice;
   cout << "You chose ";
       if (choice == 1)
        cout << "Rock. \n";
   else if (choice == 2)
        cout << "Paper. \n";
   else if (choice == 3)
        cout << "Scissors. \n";
   return (choice);
                    }
//
// doComputerTurn
//    Calculates the computer turn and displays what it chose.
//
// Parameters:
//    There are no parameters for this function.
//
// Returns:
//    Returns the computers choice.
//
int doComputerTurn(){
   int comp;
   comp = rand() % 3 + 1;
   cout << "The computer chose ";
   if (comp == 1)
        cout << "Rock. \n";
   else if (comp == 2)
        cout << "Paper. \n";
   else if (comp == 3)
        cout << "Scissors. \n";
   return (comp);
                    }
//
// showOutcome
//    Calculates and displays the winner of the current game as well as the current score.
//
// Parameters:
//    choice - The game selection made by the player.
//    comp - The game selection made by the computer.
//
// Returns:
//    This function does not have a return value.
//
void showOutcome (int choice, int comp){
int lose=0, win=0,tie=0;
   if (choice == comp){
        cout << "It's a tie! \n";
        tie++;
                      }
   else if ((choice == 1)&&(comp == 2)){
        cout << "Paper beats Rock, you lose. \n";
        lose++;
                                      }
   else if ((choice == 1)&&(comp == 3)){
        cout << "Rock beats Scissors, you win! \n" ;
        win++;
                                      }
   else if ((choice == 2)&&(comp == 1)){
        cout << "Paper beats Rock, you win! \n" ;
        win++;
                                      }
   else if ((choice == 2)&&(comp == 3)){
        cout << "Scissors beats Paper, you lose. \n";
        lose++;
                                      }
   else if ((choice == 3)&&(comp == 1)){
        cout << "Rock beats Scissors, you lose. \n";
        lose++;
                                      }
   else if ((choice == 3)&&(comp == 2)){
        cout << "Scissors beats Paper, you win! \n";
        win++;
                                   }
cout << "Wins: " << win << "   Ties: " << tie << "   Losses: " << lose << endl;
                                        }
Last edited on
I'm not asking that someone tell me exactly what to do, but just a nudge in the right direction would be appreciated. I've done a lot of reading and looking into this online, but this is my first time trying to use Functions myself.
What do you do on line 16?
(If you websearch for "c++ most vexing parse", you will notice that others make similar errors.)

What do you do on lines 30, 31, 32 and 70? How do they differ from line 16?
I feel like such an idiot... thank you so much.

I appreciate that you gave me a hint as opposed to just straight up giving me the answer. I won't be making that mistake again.
Topic archived. No new replies allowed.