Basically I'm entering an integer like 3, and it's saying its not an int.
Any help would be greatly appreciated.
Code:
#include <iostream>
#include <ctype.h>
using namespace std;
class IntRange
{
private:
int input;
int lowest;
int highest;
public:
IntRange(int, int);
int getInt();
};
IntRange::IntRange(int lower, int upper)
{
lowest = lower;
highest = upper;
}
IntRange::getInt()
{
cin >> input;
while ((input < lowest) || (input > highest) || (isdigit(input) == 0))
{
cout << "That is not a valid input, please enter a number between " << lowest << " and " << highest << endl;
cin >> input;
}
return input;
}
int main()
{
int number;
cout << "please enter a number" << endl;
IntRange validate(1, 4);
number = validate.getInt();
cout << number;
return 0;
}