You still have a new line in the stream after cin>>studentNo
, which is giving you an empty string for the classRcd
.
You could solve it by just adding another getline()
call after cin>>studentNo
and leaving alone the result, or ignore the new line by std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');