parent
707145a984
commit
ebae589e37
@ -0,0 +1,11 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project version="4"> |
||||
<component name="Encoding" defaultCharsetForPropertiesFiles="GBK"> |
||||
<file url="file://$PROJECT_DIR$/main.cpp" charset="GBK" /> |
||||
<file url="file://$PROJECT_DIR$/person" charset="GBK" /> |
||||
<file url="file://$PROJECT_DIR$/person/Person.cpp" charset="GBK" /> |
||||
<file url="file://$PROJECT_DIR$/person/students/Graduate.cpp" charset="GBK" /> |
||||
<file url="file://$PROJECT_DIR$/person/students/TeachAssistant.h" charset="GBK" /> |
||||
<file url="PROJECT" charset="GBK" /> |
||||
</component> |
||||
</project> |
@ -0,0 +1,29 @@ |
||||
#include <iostream> |
||||
#include "person/Person.h" |
||||
#include "person/students/Graduate.h" |
||||
#include "person/students/TeachAssistant.h" |
||||
|
||||
int main() { |
||||
/*
|
||||
* 因为这里的代码用到了中文,所以代码文件编码设置成了GBK,而不是UTF8(呜呜呜) |
||||
* 所以请设置好编译器及控制台相关选项,以免运行时输出乱码 |
||||
* 该项目为CMake项目,为运行方便建议使用VStudio或者clion等支持cmake的IDE打开本项目(已测试过) |
||||
*/ |
||||
|
||||
// to avoid garbled when output Chinese character
|
||||
// 防止中文乱码
|
||||
setlocale(LC_ALL, "zh-CN"); |
||||
|
||||
Person baseInformation("id233333", "Lag Seeing", Person::SEX_MALE, "ident23333", Date(2002, 9, 6)); |
||||
|
||||
Person adviserBaseInformation("id0000000", "Goos Suede", Person::SEX_MALE, "ident000000", Date(1992, 1, 1)); |
||||
Teacher adviser(adviserBaseInformation, "导师", "BEE-HIVE"); |
||||
|
||||
TeachAssistant teachAssistant(121, baseInformation, "不知道什么专业", adviser, "助教", "BEE-HIVE"); |
||||
|
||||
std::cout << teachAssistant.toString() << '\n'; |
||||
|
||||
std::cout << "\nover. If Chinese character can't be display correctly, please check the file encoding. (GBK)\n"; |
||||
|
||||
return 0; |
||||
} |
@ -1,22 +1,22 @@ |
||||
#include <iostream> |
||||
#include <sstream> |
||||
#include "Person.h" |
||||
|
||||
Person::Person(const std::string& id, const std::string &name, char sex, const std::string &identNumber, |
||||
const Date &birthday) : id(id), name(name), sex(sex), identNumber(identNumber), birthday(birthday) {} |
||||
|
||||
Person::Person(const Person &person) : id(person.id), name(person.name), sex(person.sex), |
||||
identNumber(person.identNumber), |
||||
birthday(person.birthday) {} |
||||
|
||||
std::string Person::toString() { |
||||
std::stringstream output; |
||||
output |
||||
<< "编号:" << id << '\n' |
||||
<< "姓名:" << name << '\n' |
||||
<< "性别:" << sex << '\n' |
||||
<< "身份证号:" << identNumber << '\n' |
||||
<< "出生日期:" << birthday.toString() << '\n'; |
||||
|
||||
return output.str(); |
||||
} |
||||
#include <iostream> |
||||
#include <sstream> |
||||
#include "Person.h" |
||||
|
||||
Person::Person(const std::string& id, const std::string &name, char sex, const std::string &identNumber, |
||||
const Date &birthday) : id(id), name(name), sex(sex), identNumber(identNumber), birthday(birthday) {} |
||||
|
||||
Person::Person(const Person &person) : id(person.id), name(person.name), sex(person.sex), |
||||
identNumber(person.identNumber), |
||||
birthday(person.birthday) {} |
||||
|
||||
std::string Person::toString() { |
||||
std::stringstream output; |
||||
output |
||||
<< "编号:" << id << '\n' |
||||
<< "姓名:" << name << '\n' |
||||
<< "性别:" << sex << '\n' |
||||
<< "身份证号:" << identNumber << '\n' |
||||
<< "出生日期:" << birthday.toString(); |
||||
|
||||
return output.str(); |
||||
} |
||||
|
Loading…
Reference in new issue