expected unqualified-id before '>>' token when using Strings
Apr 9, 2019 at 12:25pm UTC
I was just a begginer, so I want to know what unqualified-id is.
I was using a string with cin functions. I am confused because I don't know what unqualified ids and when to use them.
Sorry for my bad english and long code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
#include <iostream>
#include <string>
using namespace std;
struct address{
string country;
string province;
string city;
int zipcode;
string residence;
string street;
};
struct person{
string name;
string contact_no;
float height;
int age;
address addr;
};
int main()
{
person human;
//structure: Person
cout << "Name: " ;
std::string >> human.name;
std::getline(cin, human.name);
cout << "Contact# :" ;
std::string >> human.contact_no;
std::getline(cin, human.contact_no);
cout << "Height: " ;
cin >> human.height;
cout << "Age: " ;
cin >> human.age;
//structure: Address
cout << "Address" << endl;
cout << "Country: " ;
std::string >> human.addr.country;
std::getline(cin, human.addr.country);
cout << "Province: " ;
std::string >> human.addr.province;
std::getline(cin, human.addr.province);
cout << "City: " ;
std::string >> human.addr.city;
std::getline(cin, human.addr.city);
cout << "Zipcode: " ;
cin >> human.addr.zipcode;
cout << "Residence: " ;
std::string >> human.addr.residence;
std::getline(cin, human.addr.residence);
cout << "Street: " ;
std::string >> human.addr.street
std::getline(cin, human.addr.street);
cout << "Here's your input: " ;
cout << "Name: " << human.name << endl << "Contact: " << endl << human.contact_no << endl << "Height: " << human.height << endl << "Age: " << human.age << endl;
cout << "Address:" << endl;
cout << "Country: " << human.addr.country << "Province: " << human.addr.province << "City: " << human.addr.city << endl << "Zipcode: " << human.addr.zipcode << endl << "Residence: " << human.addr.residence << endl << "Street: " << human.addr.street << endl;
cout << "Sending Info to Phroton/Detron" ;
return 0;
}
Apr 9, 2019 at 12:33pm UTC
std::string >> human.name;
This makes no sense and I can see no reason why it exists. What are you trying to do here?
Last edited on Apr 9, 2019 at 12:33pm UTC
Topic archived. No new replies allowed.