在看codeproject 上的文章ATL Under the Hood 时碰到问题:
……
typedef void (*Fun)(void);
……
Fun pFun = (Fun)*(int*)*(int*)(&objClass+0);
……
本人对typedef void (*Fun)(void);
这句不是行理解,还望大虾指教,谢谢!
……
typedef void (*Fun)(void);
……
Fun pFun = (Fun)*(int*)*(int*)(&objClass+0);
……
本人对typedef void (*Fun)(void);
这句不是行理解,还望大虾指教,谢谢!
解决方案 »
- 送分-程序里嵌入一个WebBrowser,貌似默认IE6,有没有简单方法使用高级版本
- MFC中怎么画二次项曲线如ax2+bx+c+d
- 求解求解,win32下得WM_SIZE大小重置问题
- BCG OUTLOOKBAR高手进,很急
- -2147220472 是什么错误
- 字符读取的问题
- 怎样在ondraw事件里面画一个icon
- 关于m_strFilter
- vc++dialog里不见idok控件
- 如何人为制造一个非法操作,然后只能关闭?(用于软件加密,不想用TerminateProcess以免被SoftIce拦截)
- ////////////////"怎样判断文档被改变了?///////////////////////"
- 奇怪的问题。。帮忙看下。。谢
定义一个函数指针类型
还有定义成员函数指针类型,例如:
class CA;
typedef void (CA::*pmf)();
定义了一个是类CA的成员函数指针类型。
typedef type-declaration synonym;The typedef keyword defines a synonym for the specified type-declaration. The identifier in the type-declaration becomes another name for the type, instead of naming an instance of the type. You cannot use the typedef specifier inside a function definition.A typedef declaration introduces a name that, within its scope, becomes a synonym for the type given by the decl-specifiers portion of the declaration. In contrast to the class, struct, union, and enum declarations, typedef declarations do not introduce new types — they introduce new names for existing types.Example// Example of the typedef keyword
typedef unsigned long ulong;ulong ul; // Equivalent to "unsigned long ul;"typedef struct mystructtag
{
int i;
float f;
char c;
} mystruct;mystruct ms; // Equivalent to "struct mystructtag ms;"typedef int (*funcptr)(); // funcptr is synonym for "pointer
// to function returning int"funcptr table[10]; // Equivalent to "int (*table[10])();"
// to function returning int"
(1)给某一个类模板实例一个同义词;如typedef vector<int> IntVector;
(2)像上面定义一个函数指针类型;
(3)像上面定义一个成员函数指针类型。
typedef 的意义可以理解为:语句中指定的变量名,是语句中相关变量类型的绰号