-
-
Save SeanCline/c81218e4c0208ccb871268aecd7d4eff to your computer and use it in GitHub Desktop.
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 <value-ptr.hpp> | |
#include <iostream> | |
struct Base { | |
virtual void hello() const { | |
std::cout << "Hello base!\n"; | |
} | |
}; | |
struct Derived : Base { | |
void hello() const override { | |
std::cout << "Hello derived!"; | |
} | |
}; | |
int main() | |
{ | |
valuable::value_ptr<Base> basePtr = Derived{}; | |
basePtr->hello(); //< Prints: Hello base! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment