Я новичок в программировании. Во время обучения пытался написать код ниже. Проблема в том, что когда я пытаюсь получить фамилию Гамара, она не работает, просто пропускает строку с помощью getline(). Но когда я комментирую строки выше getline(), это работает. Где я ошибаюсь?
#include <iostream>
#include <string>
#include "class.h"
using std::cout;
using std::endl;
using std::cin;
using std::string;
int main(){
Person gamar;
cout<<"Enter Gamar's height: ";
cin>>gamar.height;
cout<<"Enter Gamar's weight: ";
cin>>gamar.weight;
cout<<"Enter Gamar's surname: ";
getline(cin,gamar.surname );
cout<<"Gamar's surname: "<<gamar.surname<<endl;
cout<<"Gamar's height: "<<gamar.height<<endl;
cout<<"Gamar's weight: "<<gamar.weight<<endl;
}
А вот и заголовочный файл:
using std::string;
class Person{
public:
string surname;
int weight;
int height;
};
cout<<"Enter Gamar's surname: ";
наcout<<"Enter Gamar's surname: " << endl;
. - person NutCracker   schedule 24.04.2020cin.ignore();
передgetline()
. - person Evg   schedule 24.04.2020