CPP
cpp
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
/*
* Simple code that uses the Builder pattern.
*
* For now, it just builds a few Person objects and prints their descriptions.
*/
#include <iostream>
#include <string>
using namespace std;
enum Gender {
MALE,
FEMALE
};
class Person {
private:
string name;
int age;
int heightInCm;
Gender gender;
protected:
Person(string name, int age, int heightInCm, Gender gender) :
name(name), age(age), heightInCm(heightInCm), gender(gender) {}
public:
class Builder {
private:
string name;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run