由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - C++ Q97: reference and virtual
相关主题
C++ object size一问One C++ question
C++ Q98: Call member function in virtual functionone C++ question
c++ vs Java virtual 实现(Y家)C++: what is the output? How to interpret it?
一道面试的选择题C++ Q42: (C22)
问个C++ virtual function的问题C++问题
c++疑难问题。。弱问个C++ 问题 (const_cast)
有在oracle Santa Clara工作的么?新手问个C++(Thinking in C++ source code)
one C++ question新手请教:C++ decrement loop (转载)
相关话题的讨论汇总
话题: virtual话题: sleep话题: void话题: student话题: grad
进入JobHunting版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
What is the output of the following code? Why?
#include
using namespace std;
class student {
public:
virtual void sleep() { cerr << "student sleep" << endl; }
};
class grad: public student {
public:
virtual void sleep() { cerr << "grad sleep" << endl; }
};
void exam(student& stu) {
stu.sleep();
}
void main() {
grad g;
exam(g);
}
r*******y
发帖数: 1081
2
grad sleep

【在 c**********e 的大作中提到】
: What is the output of the following code? Why?
: #include
: using namespace std;
: class student {
: public:
: virtual void sleep() { cerr << "student sleep" << endl; }
: };
: class grad: public student {
: public:
: virtual void sleep() { cerr << "grad sleep" << endl; }

1 (共1页)
进入JobHunting版参与讨论
相关主题
新手请教:C++ decrement loop (转载)问个C++ virtual function的问题
这个C++程序的运行结果是什么c++疑难问题。。
C++ Q76: singly linked list -- 这个逆序打印有什么错?有在oracle Santa Clara工作的么?
关于8皇后问题,这个解是O(n^2)吗?one C++ question
C++ object size一问One C++ question
C++ Q98: Call member function in virtual functionone C++ question
c++ vs Java virtual 实现(Y家)C++: what is the output? How to interpret it?
一道面试的选择题C++ Q42: (C22)
相关话题的讨论汇总
话题: virtual话题: sleep话题: void话题: student话题: grad