I have a extern const int variable in main.cpp which I am using in mathFunctions.cpp. If I try to modify the variable in mathFunctions.cpp, the program is failing. I am using latest verion of CodeBlocks with C++ 11.
Program works fine if I do not try to modify the variable.
//main.cpp
#include <iostream>
using namespace std;
extern const int valueTen = 10;
int addValue(int);
int main()
{
cout << addValue(2) << endl;
return 0;
}
//mathFunctions.cpp
extern int valueTen;
int addValue(int x){
valueTen++; //program stops because of this line
return x + valueTen;
}