Skip to content

Commit f1bf7e9

Browse files
committed
Additional updates adding PHONE_TYPE_ to enum options
1 parent 23fd7ae commit f1bf7e9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

content/getting-started/cpptutorial.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ any particular field definition, see the
276276
277277
The generated code includes a `PhoneType` enum that corresponds to your `.proto`
278278
enum. You can refer to this type as `Person::PhoneType` and its values as
279-
`Person::MOBILE`, `Person::HOME`, and `Person::WORK` (the implementation details
280-
are a little more complicated, but you don't need to understand them to use the
279+
`Person::PHONE_TYPE_MOBILE`, `Person::PHONE_TYPE_HOME`, and
280+
`Person::PHONE_TYPE_WORK` (the implementation details are a little more
281+
complicated, but you don't need to understand them to use the
281282
enum).
282283
283284
The compiler has also generated a nested class for you called
@@ -394,11 +395,11 @@ void PromptForAddress(tutorial::Person* person) {
394395
string type;
395396
getline(cin, type);
396397
if (type == "mobile") {
397-
phone_number->set_type(tutorial::Person::MOBILE);
398+
phone_number->set_type(tutorial::Person::PHONE_TYPE_MOBILE);
398399
} else if (type == "home") {
399-
phone_number->set_type(tutorial::Person::HOME);
400+
phone_number->set_type(tutorial::Person::PHONE_TYPE_HOME);
400401
} else if (type == "work") {
401-
phone_number->set_type(tutorial::Person::WORK);
402+
phone_number->set_type(tutorial::Person::PHONE_TYPE_WORK);
402403
} else {
403404
cout << "Unknown phone type. Using default." << endl;
404405
}
@@ -494,13 +495,13 @@ void ListPeople(const tutorial::AddressBook& address_book) {
494495
const tutorial::Person::PhoneNumber& phone_number = person.phones(j);
495496
496497
switch (phone_number.type()) {
497-
case tutorial::Person::MOBILE:
498+
case tutorial::Person::PHONE_TYPE_MOBILE:
498499
cout << " Mobile phone #: ";
499500
break;
500-
case tutorial::Person::HOME:
501+
case tutorial::Person::PHONE_TYPE_HOME:
501502
cout << " Home phone #: ";
502503
break;
503-
case tutorial::Person::WORK:
504+
case tutorial::Person::PHONE_TYPE_WORK:
504505
cout << " Work phone #: ";
505506
break;
506507
}

0 commit comments

Comments
 (0)