mirror of https://github.com/CppCon/CppCon2014.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
596 B
C++
31 lines
596 B
C++
// Puzzler: see comment at bottom for the question
|
|
// (PLEASE don't say anything about the REASON, just answer the question!)
|
|
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
class Base
|
|
{
|
|
public:
|
|
virtual void func()
|
|
{
|
|
cout << "Base's func() now running\n";
|
|
}
|
|
};
|
|
|
|
class Derived : public Base
|
|
{
|
|
public:
|
|
void func()
|
|
{
|
|
Base:func();
|
|
cout << "Derived's func() now running\n";
|
|
}
|
|
};
|
|
|
|
int main()
|
|
{
|
|
Base *bp = new Derived;
|
|
bp->func(); // Question: What's the runtime behavior?
|
|
}
|