Pipe is a worm hole connecting C and C++
In C programming language, the observer design pattern is implemented with function pointer (aka callback function). But in Qt library, it introduces signal and slot. How to link a callback function from the C callback function to the C++ siganl and slot is a problem I encounter. Call back function can only be static, but signal and slot can not. There are some triky way to pretend a non-static function to a static function. But the easiest way is to use pipe. the callback function create a pipe and do the read operation, while the siganl function wait for and read at the other end of the pipe.
The pipe is like a worm hole connecting C and C++, two different time and space. How cool!
相关文档:
http://www.vckbase.com/document/viewdoc/?id=1711
作者:求是赤子
一、系统环境
Linux 操作系统 kernel2.4.2,安装 gsoap2.6 到目录/usr/local/gsoap
二、gSOAP 的简要使用例子
下面是一个简单的例子,实现一个加法运算的 WebService,具体功能是客户端(client)输入 num1 和 num2,服务器端(server)返回 num ......
1、 经常看见return EXIT_SUCCESS或return EXIT_FAILURE,但都不知这两个来自何处,现在才知原来stdlib.h定义了EXIT_SUCCESS和EXIT_FAILURE符号。
在stdlib.h头文件里:
#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
& ......
转至http://www.pconline.com.cn/pcedu/empolder/gj/c/0503/566020.html
函数存放在内存的代码区域内,它们同样有地址,我们如何能获得函数的地址呢?
如果我们有一个int test(int a)的函数,那么,它的地址就是函数的名字,这一点如同数组一样,数组的名字就是数组的起始地址。
定义一个指向函数的指针用如下 ......
1、局部变量能否和全局变量重名?
答:能,局部会屏蔽全局。要用全局变量,需要使用"::" ;局部变量可以与全局变量同名,在函数内引用这个变量时,会用到同名的局部变量,而不会用到全局变量。对于有些编译器而言,在同一个函数内可以定义多个同名的局部变量,比如在两个循环体内都定义一个同名的局部变量,而那 ......
1.介绍一下STL,详细说明STL如何实现vector.
Answer:
STL (标准模版库,Standard Template Library.它由容器算法迭代器组成。
STL有以下的一些优点:可以方便容易地实现搜索数据或对数据排序等一系列的算法;调试程序时更加安全 和方便;即使是人们用STL在 ......