Remember to checkout the Codesnip below to review the C++ code yourself! Feel free to copy the code, but I ask that you please provide credit if you leave the code unchanged when you use it.
//Programmer: Nazmus //Program: Global vs. Local Variables //Website: EasyProgramming.net #include <iostream> #include <string> using namespace std; string var = "This is a global variable"; void variable(); int main() { cout << var << endl; string var = "This is a local variable"; cout << var << endl; cout << ::var << endl; variable(); cin.get(); cin.ignore(); //system("pause"); } void variable() { cout << var << endl; }