⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 employee.c

📁 c语言是面向过程的程序语言
💻 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>/*-----------------------------*//*   employee implementation   *//*-----------------------------*/#define IMPLEMENTATION#include <employee.h>/*  ---------------------  Object implementation  ---------------------*/voidconstMethodOvldDecl(print, person){  sendCMsg(this, person, print);  printf("\tdept:\t%s\n", sub_cast(this,person)->m.department);}OBJECT_IMPLEMENTATION  SUPERCLASS(person)ENDOF_IMPLEMENTATION/*  --------------------  Class implementation  --------------------*/initClassDecl() /* required */{  /* initialize super class */  initSuper(person);  /* overload super class methods */  overload(person.print) = methodOvldName(print, person);}dtorDecl() /* required */{  person._person(super(this,person));  free((void*)this->m.department);  this->m.department = NULL;}t_employeeclassMethodDecl_(*const new)     char const name[], char const department[] __{  t_employee *const this = employee.alloc();  if (this) employee.init(this, name, department);  return this;}voidmethodDecl_(init)     char const name[], char const department[] __{  person.init(super(this,person), name);  this->m.department = strdup(department);}voidmethodDecl_(copy) t_employee const*const emp __{  employee._employee(this);  employee.init(this, emp->m.person.m.name, emp->m.department);}CLASS_IMPLEMENTATION  methodName(new),  methodName(init),  methodName(copy)ENDOF_IMPLEMENTATION

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -