2013年10月17日
摘要: C++中没有super或parent关键字,想要调父类方法,只能使用明确的[父类名称::方法名]假如要求A和B是C的父类的前提下,要使如下代码能够分别输出A和B的相关信息(虽然这个要求很少遇到....,但是面试官就是这么变态)int main(int argc, char* argv[]){ C c; A* pA = &c; B* pB = &c; pA->foo(); //这里会输出和A相关的信息 pB->foo(); //这里会输出和B相关的信息 return 0;} 怎么办?// test.cpp : Defines the entry poi... 阅读全文
posted @ 2013-10-17 01:31 yangyh 阅读(5611) 评论(0) 推荐(0) 编辑