I have code like this:
// .h file
#include <iostream>
#include <limits>
class MyClass
{
public:
myInput();
int inputValue;
}
// .cpp file
#include "MyClass.h"
void MyClass::myInput()
{
std::cin >> inputValue;
if (!std::cin)
{
//fix error
std::cin.clear();
std::cin.ignore(std::numeric_limits < std::streamsize >::max(), '\n');
}
}
During compilation, the compiler is showing error:
Expected an identifier
In the line with
std::cin.ignore(std::numeric_limits < std::streamsize >::max(), '\n');
Moreover, the ::max()
is underlined. I don't have an idea what is going on. Thanks for help!
Problem has solved. I'm using Visual Studio which have macro called max. So I added #undef max; at the begin of my file and everything is working. Thanks for help.