首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

void(Derived:pfn)() = &Base:foo1;编译有关问题

2012-11-08 
void(Derived::*pfn)() &Base::foo1编译问题已知类Base和Derived的定义如下:C/C++ codestruct Base {in

void(Derived::*pfn)() = &Base::foo1;编译问题
已知类Base和Derived的定义如下:

C/C++ code
struct Base {int data1;void foo1();};struct Derived:public Base{int data2;void foo2();};

请问下述哪些代码是可以正常编译通过的?
A.int Base::*p = &Derived::data2;
B.int Derived::*p = &Base::data1;
C.void(Base::*pfn)() = &Derived::foo2;
D.void(Derived::*pfn)() = &Base::foo1;
E.void(Base::*pfn)() = &Derived::foo1;
F.int Base::*p = &Derived::data1;


[解决办法]
当然是自己先试,手懒是学不好编程的。
试出来不懂的再来问。
另外,买本合格的教材,你直接就学会答案了,根本就不该有这个浪费生命的行为的。
[解决办法]
一般看《C++ Primer》,收藏《The C++ Programming Language》
Effective C++和More Effective C++、effective stl、exceptional c++、more exceptional c++、exceptional c++ style为后续的必看书籍。

热点排行