- #1
sweetjones
- 44
- 0
Is there a certain order that you have to include header files? I have an already error free program in c++, but when i insert some code to change the background and foreground of the console application it gives me errors. It's when i include the windows.h I get the errors. When i comment out the color change code and the windows.h line it compiles with NO errors. The errors I'm getting is:
Test6.cpp(146) : error C2065: 'numeric_limits' : undeclared identifier
Test6.cpp(146) : error C2062: type 'int' unexpected
Test6.cpp(146) : warning C4003: not enough actual parameters for macro 'max'
Test6.cpp(146) : error C2589: '(' : illegal token on right side of '::'
Test6.cpp(155) : error C2062: type 'int' unexpected
Test6.cpp(155) : warning C4003: not enough actual parameters for macro 'max'
Test6.cpp(155) : error C2589: '(' : illegal token on right side of '::'
Test6.cpp(155) : error C3861: 'numeric_limits': identifier not found, even with argument-dependent lookup
It's from these lines of code in my program which is just input validation:
bool numbercheck(int& integer)
{
if (cin)
{
cin.ignore(numeric_limits<int>::max(), '\n');
if (cin.gcount() == 1)
wrong = true;
//cout << "YOU GOT IT RIGHT!" << endl;
return true;
}
else
{
cin.clear();
cin.ignore(numeric_limits<int>::max(), '\n');
cout << "\n\nWRONG CHARACTER! TRY AGAIN..." << endl;
cout << endl;
return false;
}
}
When i comment these 2 lines out: cin.ignore(numeric_limits<int>::max(), '\n'); and leave the color change code and windows.h in, it compiles with NO errors. I need those 2 lines of code for my program to validate correctly. Do I have to insert the color change code and the "#include <windows.h>" in a certain part of my code for them to work together?
Thanx in Advance!
Test6.cpp(146) : error C2065: 'numeric_limits' : undeclared identifier
Test6.cpp(146) : error C2062: type 'int' unexpected
Test6.cpp(146) : warning C4003: not enough actual parameters for macro 'max'
Test6.cpp(146) : error C2589: '(' : illegal token on right side of '::'
Test6.cpp(155) : error C2062: type 'int' unexpected
Test6.cpp(155) : warning C4003: not enough actual parameters for macro 'max'
Test6.cpp(155) : error C2589: '(' : illegal token on right side of '::'
Test6.cpp(155) : error C3861: 'numeric_limits': identifier not found, even with argument-dependent lookup
It's from these lines of code in my program which is just input validation:
bool numbercheck(int& integer)
{
if (cin)
{
cin.ignore(numeric_limits<int>::max(), '\n');
if (cin.gcount() == 1)
wrong = true;
//cout << "YOU GOT IT RIGHT!" << endl;
return true;
}
else
{
cin.clear();
cin.ignore(numeric_limits<int>::max(), '\n');
cout << "\n\nWRONG CHARACTER! TRY AGAIN..." << endl;
cout << endl;
return false;
}
}
When i comment these 2 lines out: cin.ignore(numeric_limits<int>::max(), '\n'); and leave the color change code and windows.h in, it compiles with NO errors. I need those 2 lines of code for my program to validate correctly. Do I have to insert the color change code and the "#include <windows.h>" in a certain part of my code for them to work together?
Thanx in Advance!