#include <windows.h> (...) cin.ignore(numeric_limits<streamsize>::max(), '\n');

1
2
3
4
5
6
7
8
9
10
11
#include "stdafx.h"
#include <string>
#include <iostream>
#include <fstream>
#include <limits>
#include <time.h> //srand( time(0) );
#include "templates.h"
#include "classes.h"
#include <windows.h>

using namespace std;


1
2
3
4
5
6
7
8
9
	int menuChoice = 0, menuMax=2;
	while ((cout << "Choose menu option between 1 and " << menuMax << ":\n"
		<< "1: initialization(x)\n"
		<< "2: loadGameData(x)" << endl) && (!(cin >> menuChoice) || menuChoice < 1 || menuChoice > menuMax))
	{
		cout << "That's not a number between 1 and " << menuMax << "!\n";
		cin.clear();
		cin.ignore(numeric_limits<streamsize>::max(), '\n');
	}


When I add #include <windows.h> at the top (because I want to use wait(milliseconds)), I get the following error:

error C2589: '(' : illegal token on right side of '::'


Please help!
windows.h has a macro called 'max' so you need to undefine it: #undef max after you included it.
and before #include <limits>

Thank you!
Topic archived. No new replies allowed.