由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - C++ Q98: Call member function in virtual function
相关主题
C++ object size一问C++ Q60 calling virtual function in constructor (JPMorgan)
C++ Q97: reference and virtual贡献一道 C++ 题目
c++ vs Java virtual 实现(Y家)C++ online Test 一题
virtual table存在memory的哪块啊?C++ virtrual destructor
One C++ questionvirtual destructor (C++)问题
one C++ question?Can we define pure virtual function?
C++ Q36: derivation specification (B8_9)C++里面能否检测一个虚函数是否被重载?
C++ Q40: virtual destructor (C2)各位总结一下区别:virtual function and virtual destructor?
相关话题的讨论汇总
话题: base话题: void话题: pay话题: derived话题: function
进入JobHunting版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
What is the output of the following code? Why?
#include
using namespace std;
class base {
public:
void pay() { cout << "Base::pay" << endl; }
virtual void eat() { pay(); }
};
class derived: public base {
public:
void pay() { cout << "Derived::pay" << endl; }
};
void main() {
base* p = new derived;
p->eat();
}
r*******y
发帖数: 1081
2
Base::pay

【在 c**********e 的大作中提到】
: What is the output of the following code? Why?
: #include
: using namespace std;
: class base {
: public:
: void pay() { cout << "Base::pay" << endl; }
: virtual void eat() { pay(); }
: };
: class derived: public base {
: public:

1 (共1页)
进入JobHunting版参与讨论
相关主题
各位总结一下区别:virtual function and virtual destructor?One C++ question
一道面试的选择题one C++ question?
问个C++ virtual function的问题C++ Q36: derivation specification (B8_9)
c++疑难问题。。C++ Q40: virtual destructor (C2)
C++ object size一问C++ Q60 calling virtual function in constructor (JPMorgan)
C++ Q97: reference and virtual贡献一道 C++ 题目
c++ vs Java virtual 实现(Y家)C++ online Test 一题
virtual table存在memory的哪块啊?C++ virtrual destructor
相关话题的讨论汇总
话题: base话题: void话题: pay话题: derived话题: function