Skip to content

Instantly share code, notes, and snippets.

@sccolbert
Last active September 21, 2020 01:20
Show Gist options
  • Save sccolbert/5e36bf2cbf61a2d56ebb605ab789796f to your computer and use it in GitHub Desktop.
Save sccolbert/5e36bf2cbf61a2d56ebb605ab789796f to your computer and use it in GitHub Desktop.
Initialization
#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