Last active
September 21, 2020 01:20
-
-
Save sccolbert/5e36bf2cbf61a2d56ebb605ab789796f to your computer and use it in GitHub Desktop.
Initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Foo { | |
public: | |
Foo() { | |
std::cout << this->getValue(); | |
} | |
virtual int getValue() = 0; | |
}; | |
class Bar: public Foo { | |
public: | |
Bar(int value): n(value) { } | |
int getValue() { | |
return this->n; | |
} | |
private: | |
int n; | |
}; | |
int main() { | |
Bar bar(42); // What is the output of this line? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment