首页 > 移动平台 > 详细

Wrapper Function 包装函数 包裹函数

时间:2020-07-01 20:03:32      阅读:61      评论:0      收藏:0      [点我收藏+]

在一个函数A中只有调用另一个函数B,可以把函数A叫做函数B的包装函数.

function A (int i)
{
  B (i)
}

这个函数的具体功能是由函数B来实现的,函数A是函数B的接口.

举一个UNIX网络编程的实例:

int Socket(int family, int type, int protocol)
{
  int n;
  if ( (n = socket(family, type, protocol)) < 0)
    err_sys("socket error"); // customized error function
  return (n);
}

socket的函数被包装在Socket里面,Socket函数是自定义函数,在里面可以加入简单的error handling.

 

 

 

 

A wrapper function for a class method is shown in the following code fragment from the bigtime.cpp
example:

/*
* ======== clockPrd ========
* Wrapper function for PRD objects calling
* Clock::tick()
*/
void clockPrd(Clock clock)
{
clock.tick();
return;
}

Any additional parameters that the class method requires can be passed to the wrapper function.

Wrapper Function 包装函数 包裹函数

原文:https://www.cnblogs.com/sdb1942/p/13220906.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!