| <<< Problem with function definitions, cont. | Index | Make ping-pong better >>> |
The problem is easily solved by adding function declarations:
#include <iostream>
// function declarations:
void ping();
void pong();
int shot_count = 0;
void ping()
{
if ( shot_count > 6 ) return;
++shot_count; // count each shot
std::cout << " ping! ";
pong();
}
void pong()
{
if ( shot_count > 6 ) return;
++shot_count; // count each shot
std::cout << " pong! ";
ping();
}
int main()
{
ping(); // lets play!
std::cout << "\n Game over!\n";
return 0;
}
| <<< Problem with function definitions, cont. | Index | Make ping-pong better >>> |