📄 manager.c
字号:
/* ****************************** * Object Oriented Programming in C * * Author: Laurent Deniau, Laurent.Deniau@cern.ch * * For more information, please see the paper: * http://home.cern.ch/ldeniau/html/oopc/oopc.html * ****************************** */#include <stdio.h>/*-----------------------------*//* manager implementation *//* inherit from employee *//*-----------------------------*/#define IMPLEMENTATION#include <manager.h>/* --------------------- Object implementation ---------------------*/voidconstMethodOvldDecl(print, person){ sendCMsg(this, employee, person.print); sendCMsg(super(sub_cast(this,employee.m.person),education),education,print); printf("\tlevel:\t%d\n", sub_cast(this,employee.m.person)->m.level);}OBJECT_IMPLEMENTATION SUPERCLASS (employee), SUPERCLASS (education)ENDOF_IMPLEMENTATION/* -------------------- Class implementation --------------------*/initClassDecl() /* required */{ /* initialize super class */ initSuper(employee); initSuper(education); /* overload super class methods */ overload(employee.person.print) = methodOvldName(print, person); /* default level */ objDefault(level) = 1;}dtorDecl() /* required */{ employee._employee(super(this,employee)); education._education(super(this,education));}t_managerclassMethodDecl_(*const new) char const name[], char const department[], char const diploma[], int level __{ t_manager *const this = manager.alloc(); if (this) manager.init(this, name, department, diploma, level); return this;}voidmethodDecl_(init) char const name[], char const department[], char const diploma[], int level __{ employee.init(super(this,employee), name, department); education.init(super(this,education), diploma); this->m.level = level;}voidmethodDecl_(copy) t_manager const*const mng __{ manager._manager(this); manager.init(this, mng->m.employee.m.person.m.name, mng->m.employee.m.department, mng->m.education.m.diploma, mng->m.level);}CLASS_IMPLEMENTATION methodName(new), methodName(init), methodName(copy)ENDOF_IMPLEMENTATION
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -