This file contains hidden or 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 <new> | |
struct Parent { }; | |
struct Child : Parent { }; | |
struct Tag { }; | |
int main() | |
{ | |
const Child c; |
This file contains hidden or 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
struct Parent { virtual ~Parent(); }; | |
struct Child : private virtual Parent { }; | |
int main() | |
{ | |
Child aa; | |
Parent& pp = (Parent&)(aa); // OK ( [expr.cast]/p4.6 ), chooses static_cast | |
Child& aa = (Child&)(pp) // FAILS, chooses static_cast, but that would fail | |
// because Parent is a virtual base ( [expr.static.cast]/p2 ) |