/
githubmirror
/
CPlusPlusThings
Обзор
Документация
Войти
/
githubmirror
/
CPlusPlusThings
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
basic_content/this/person.cpp
32 строки
543 B
zhangxing
support bazel complie this project and format code.
30 мар 2024, 17:00
30 мар 2024, 17:00
3c8a3f2
Код
Авторство
О чём код?
#include <cstring> #include <iostream> using namespace std; class Person { public: typedef enum { BOY = 0, GIRL } SexType; Person(char *n, int a, SexType s) { name = new char[strlen(n) + 1]; strcpy(name, n); age = a; sex = s; } int get_age() const { return this->age; } Person &add_age(int a) { age += a; return *this; } ~Person() { delete[] name; } private: char *name; int age; SexType sex; }; int main() { Person p("zhangsan", 20, Person::BOY); cout << p.get_age() << endl; return 0; }