Hello imthekingbabyz,
To answer your question, No.
By using
cin >>
you have to enter something. You can not just press enter to pass it. Therefore the least you could enter is a zero. And deal with it later if needed.
The first potential problem I see is line 1. I am not sure if that would the "#include"s that follow. I have always seen line 1 follow the "#include"s. Any way it is best not to use line 1 in the first place.
By placing all the variables in the class in "public" you are defeating the point of the class and might as well use a struct.
The class would be better as:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
class Student
{
public:
Student(); // <--- Default ctor and dtor.
~Student();
void output( );
private:
string FirstName;
string LastName;
double GPA;
double ACT;
double SAT;
};
| |
I do have a suggestion when you enter for the first and last names "std::getline" would work better.
std::cin >>
will only extract from the input buffer up to the first white space or new line whichever comes first. Then the next
std::cin >>
will extract what is left in the input buffer with out waiting for keyboard input. This will cause a problem.
Using "std::getline" will require the last "cin >>" to be followed with
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Requires header file <limits>.
I do not know what the idea of this program is for. If it is for testing the input then I would not put much more into fixing it. If you want to enter more than two students then the program needs reworked or it will get very large very fast.
Hope that helps for now,
Andy