Yes I know using namespace std
is bad practice, but I have already written a majority of the code with this declaration in place, and I don't think I have the time to go back and modify it.
The reason for the global variable is that I'm using multiple threads which need access to this variable and need to modify it.
My question is, I have int remainder = 0;
declared globally, and within my master thread I call remainder = 13 % 5;
for example.
This gives me an error saying 'int remainder' redeclared as a different kind of symbol
and I've read that the reason is that using namespace std
overrides the std::modulus
operator, if I understood that correctly.
What other methods can I use to perform this function, keeping using namespace std
and remainder
as a global variable?
#include<iostream>
#include<cmath>
using namespace std;
int remainder = 0;
void testing();
int main(){
testing();
cout << remainder << endl;
return 0;
}
void testing(){
remainder = 13 % 5;
}