#include <iostream>
usingnamespace std;
class something
{
private:
int a;
public :
something(int b=1)
{
a=b;
}
void the_function()
{
cout << "enter #1 :\n";
cin >> a;
while (a!=1) // is it possible to make this skip to the default, if user enters invalid entry?
{cout << "try again";
cin >> a;
}
}
void display()
{cout << a;}
};
int main ()
{
something obj1;
obj1.the_function();
obj1.display();
}
.. so instead of looping through the while statement, once an invalid entry has been made, is there anyway to make the default value be used for 'a' and skip right to the display function? thanks for any help