| <<< Problem with function definitions | Index | Solution: function declarations (prototypes) >>> |
Let's try a ping-pong program: :
#include <iostream>
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 | Index | Solution: function declarations (prototypes) >>> |