Commit 78709f20 authored by Jan Tattermusch's avatar Jan Tattermusch

fix C++ example

parent 69c14071
...@@ -32,7 +32,7 @@ void PromptForAddress(tutorial::Person* person) { ...@@ -32,7 +32,7 @@ void PromptForAddress(tutorial::Person* person) {
break; break;
} }
tutorial::Person::PhoneNumber* phone_number = person->add_phone(); tutorial::Person::PhoneNumber* phone_number = person->add_phones();
phone_number->set_number(number); phone_number->set_number(number);
cout << "Is this a mobile, home, or work phone? "; cout << "Is this a mobile, home, or work phone? ";
...@@ -77,7 +77,7 @@ int main(int argc, char* argv[]) { ...@@ -77,7 +77,7 @@ int main(int argc, char* argv[]) {
} }
// Add an address. // Add an address.
PromptForAddress(address_book.add_person()); PromptForAddress(address_book.add_persons());
{ {
// Write the new address book back to disk. // Write the new address book back to disk.
......
...@@ -8,17 +8,17 @@ using namespace std; ...@@ -8,17 +8,17 @@ using namespace std;
// Iterates though all people in the AddressBook and prints info about them. // Iterates though all people in the AddressBook and prints info about them.
void ListPeople(const tutorial::AddressBook& address_book) { void ListPeople(const tutorial::AddressBook& address_book) {
for (int i = 0; i < address_book.person_size(); i++) { for (int i = 0; i < address_book.persons_size(); i++) {
const tutorial::Person& person = address_book.person(i); const tutorial::Person& person = address_book.persons(i);
cout << "Person ID: " << person.id() << endl; cout << "Person ID: " << person.id() << endl;
cout << " Name: " << person.name() << endl; cout << " Name: " << person.name() << endl;
if (person.has_email()) { if (person.email() != "") {
cout << " E-mail address: " << person.email() << endl; cout << " E-mail address: " << person.email() << endl;
} }
for (int j = 0; j < person.phone_size(); j++) { for (int j = 0; j < person.phones_size(); j++) {
const tutorial::Person::PhoneNumber& phone_number = person.phone(j); const tutorial::Person::PhoneNumber& phone_number = person.phones(j);
switch (phone_number.type()) { switch (phone_number.type()) {
case tutorial::Person::MOBILE: case tutorial::Person::MOBILE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment