I am writing a program which gets integer data from a user. I want the option to default the data if the user simply presses return. I have a class constructor which will set the default. I am only familiar with CIN which forces me to enter something. Is there something else and how do you use it?
Perhaps you could use std::cin to get the data into the variable, and if the variable is empty, then set it to the default value? If you really want to keep it in the class and initialize it with the constructor, you could get the data into a temporary variable and if it is not empty, assign it to the variable, and otherwise discard the input...
thanks for your help. What I ended up doing was to use the cin.getline. I take in the characters then convert to int. Because getline reads all the characters, including the carriage return, that did not convert to int and my default values loaded in the default constructor. This was part of a homework assignment.