C++ examples for Function:Function Creation
Two different local variables with the same name.
#include <iostream> using namespace std; int get_age(); // Prototype int main()// ww w . j a va 2s . c o m { int age; cout << "What is your age? "; cin >> age; get_age(); // Call the second function. cout << "main()'s age is still " << age << "\n"; return 0; } int get_age() { int age; cout << "What is your age again? "; cin >> age; return 0; }