`
javayestome
  • 浏览: 1041254 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

pointer to function and pointer to member function

阅读更多
<essential c++>的确很好,不过功力未足,看至后面便云里雾里了。
#include<iostream>
#include
<vector>

usingnamespacestd;

classF
...{
public:
F()
...{}
stringfunctionA(stringa)
...{
cout
<<"itisA"<<endl;
returna;
}

stringfuncionB(stringb)
...{
cout
<<"itisB"<<endl;
returnb;
}


}
;

intadd(inta,intb)
...{
returna+b;
}


intsub(inta,intb)
...{
returna-b;
}


int_tmain(intargc,_TCHAR*argv[])
...{
/**//*pointertomemberfunction*/
Ff;
string(F::*p)(stringa);
p
=&F::functionA;
(f.
*p)("a");
p
=&F::funcionB;
(f.
*p)("b");


/**//*poinertofunction*/
int(*q)(inta,intb);
q
=&add;
cout
<<(*q)(1,2)<<endl;
q
=&sub;
cout
<<(*q)(1,2)<<endl;


return0;
}

分享到:
评论

相关推荐

    this pointer is not available in non-member function(解决方案).md

    this pointer is not available in non-member function(解决方案).md

    c++ event示例

    The first way is to call a global function through a function pointer that is a private member of your class. The client has to set that function pointer if it wants to handle that event. So, your ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Tabs Function Declarations and Definitions Function Calls Conditionals Loops and Switch Statements Pointer and Reference Expressions Boolean Expressions Return Values Variable and Array ...

    数位板压力测试

    This specification was developed in response to a perceived need for a standardized programming inter-face to digitizing tablets, three dimensional position sensors, and other pointing devices by a ...

    Google C++ Style Guide_英文版.pdf

    ### Google C++ Style Guide ...- **Pointer and Reference Expressions:** Place asterisks and ampersands next to the type rather than the variable. - **Boolean Expressions:** Use logical AND (`&&`)...

    SourceInsight4.0.0089

    For example: void SomeClass::Function() : member{x} 3. C++: support for digit separators. Eg: int x = 234'000; 4. C++: lambda functions: misc fixes: capture variables by reference, trailing return ...

    source insight 4.0.0089

    For example: void SomeClass::Function() : member{x} Fix: C++: support for digit separators. Eg: int x = 234'000; Fix: C++: lambda functions: misc fixes: capture variables by reference, trailing ...

    深度探索C++对象模型 超清版

    4.4 指向Member Functions的指针(Pointer-to-Member Functions) 支持“指向Virtual Member Functions”之指针 在多重继承之下,指向Member Functions的指针 “指向Member Functions之指针”的效率 4.5 Inline ...

    一个跨平台的CString源码

    // the Standard C++ Library basic_string&lt;&gt; template and add to it the // the following conveniences: // - The full MFC CString set of functions (including implicit cast) // - writing to/reading ...

    DIBSection Class VB

    You need to modify the declare provided for this in the VB API guide because this declare assumes you cannot use the pointer to the bitmap returned by the function and simply discards it. Here are ...

    Addison.Wesley.C++.by.Dissection.2002.pdf

    - **Getting Ready to Program:** Discusses the setup required to write and run C++ programs. - **A First Program:** Provides a simple example program, typically "Hello, World!" to illustrate the syntax...

    BCGControlBarPro.v12.00

    CBCGPRibbonBar::AddBackstageCategory returns a pointer to the new class object - CBCGPRibbonBackstageViewPanel. Usually, you'll need to call the following class methods to create your backstage view: ...

    Turbo C++ 3.0[DISK]

    special offer, and write for full details on how to receive a free IntroPak containing a $15 credit toward your first month's on-line charges. 2. Check with your local software dealer or users' ...

    Turbo C++ 3.00[DISK]

    special offer, and write for full details on how to receive a free IntroPak containing a $15 credit toward your first month's on-line charges. 2. Check with your local software dealer or users' ...

    微软内部资料-SQL性能优化5

    Sysindexes contains a pointer to the first IAM page, and each IAM page contains a pointer to the next one. The Difference between Clustered and Nonclustered Indexes The main difference between the ...

    《深度探索C++对象模型》(Stanley B·Lippman[美] 著,侯捷 译)

    4.4 指向Member Functions的指针(Pointer-to-Member Functions) 支持“指向Virtual Member Functions”之指针 在多重继承之下,指向Member Functions的指针 “指向Member Functions之指针”的效率 4.5 Inline ...

    A port of the original STL to many platforms

    4. 配件:包括函数对象(functors,如用于比较的less或用于转换的plus)、指针算子(pointer-to-function and pointer-to-member)、分配器(allocator,控制内存分配策略)等,它们为STL提供额外的灵活性和定制性。...

    Using DIB Sections in VB

    You need to modify the declare provided for this in the VB API guide because this declare assumes you cannot use the pointer to the bitmap returned by the function and simply discards it. Here are ...

    [原创]自己工作中常用的模板库,简化你的工作

    ☆ helper function to pack multi-parameters into unary function.(it is hard to write unary function object type) ◆ [paramPackage.hpp] ★ 实现了把任意多个(最多7个,可简易扩充),任意类型的参数封装...

Global site tag (gtag.js) - Google Analytics