Guest User

Untitled

a guest
Jun 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. class Foo{
  2. };
  3.  
  4. class Bar : Foo{
  5. public:
  6. Foo* asFoo(){
  7. return (Foo*)(this);
  8. }
  9. };
  10.  
  11. int main(){
  12. //Foo x = Bar();
  13. // error: ‘Foo’ is an inaccessible base of ‘Bar’
  14. //Foo y = (Foo)Bar();
  15. // error: ‘Foo’ is an inaccessible base of ‘Bar’
  16. Foo z = *(Bar().asFoo());
  17. // OK
  18. }
Add Comment
Please, Sign In to add comment