fork download
  1.  
  2. namespace Fuzzy { class CuteDog; }
  3.  
  4. using namespace Fuzzy;
  5. class PuppyArmy {
  6. public:
  7. CuteDog *cute;
  8. void f();
  9. };
  10.  
  11. namespace Fuzzy {
  12. struct X { virtual ~X() {} };
  13. class CuteDog : public X {};
  14. }
  15.  
  16. Fuzzy::X* foo() { return 0; }
  17. namespace Tough {}
  18. using namespace Tough;
  19.  
  20. void PuppyArmy::f() {
  21. cute = dynamic_cast< ::Fuzzy::CuteDog*>(foo()); // where foo() returns the parent class of CuteDog*
  22. }
  23. int main () {}
  24.  
Success #stdin #stdout 0.01s 2720KB
stdin
Standard input is empty
stdout
Standard output is empty