-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ece784
commit 1e64fe2
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <MyLib/myLogerDef.h> | ||
|
||
using namespace MyLib::MyLoger; | ||
|
||
/** | ||
* @brief 工厂模式学习前置任务之:静态创建方法: | ||
* 需求:假设需要设计一个员工管理系统, | ||
* 目前是创业初期,部门内只有程序员一个职位, | ||
* 使用静态创建方法对该需求进行建模。 | ||
*/ | ||
|
||
/** | ||
* @brief 程序员类 | ||
*/ | ||
struct Programer | ||
{ | ||
Programer(void) { | ||
CORRECT_LOG("Create a porgramer object complete.\n"); | ||
} | ||
}; | ||
|
||
/** | ||
* @brief 部门类,负责各个职员类的创建 | ||
*/ | ||
struct Department | ||
{ | ||
/** | ||
* @brief Create a Programer object。 | ||
*/ | ||
static Programer * createProgramer(void) | ||
{ | ||
NOTIFY_LOG("Department class create a porgramer object.\n"); | ||
return new Programer(); | ||
} | ||
}; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
Programer * newProgamer = Department::createProgramer(); | ||
|
||
delete newProgamer; | ||
|
||
return EXIT_SUCCESS; | ||
} |