Sunday, 10 March 2013

Week 6 day 1

Today I learned about global variables. There are variables that can be called from any function in the program. For example;

#include <iostream>
using namespace std;
int myInt = 6; //This is your global variable

int main()
{
    cout << myInt;
    return 0;
}
that is a basic global variable program. Using global variables are very dangerous though, as they are shared data that any other function can change the data to. Which in turn creates a bug that is very challenging to find.

No comments:

Post a Comment