Welcome to the Snail Races - C++

In the “The Snail Racing Game,” be sure to watch for instances that relate to the following points:

  • There is only one global variable (money). It is global because it is declared outside of functions.
  • money is used as a local variable in the race() function and as a global variable; the default is the local variable; however, whenever money is used as a global variable, the scope resolution operator (::) is used.
  • This example has two versions of the race() function. They take different arguments. These two race() functions are an example of overloading functions.

Now, for some mood setting: Do you ever find yourself wishing that time would go just a little slower? Go to the snail races and that wish will come true. (Don’t worry, eventually, one of the cute little critters will win, but you could be there a while.)

This program is a basic racing program; feel free to add to it and make it more exciting.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

C++ Topics