fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class figure
  6. {
  7. public:
  8. virtual ~figure(){}
  9. };
  10.  
  11. class Pawn : public figure
  12. {
  13. public:
  14. virtual ~Pawn(){}
  15. };
  16.  
  17. void value(figure fi)
  18. {
  19. cout << "val typeid check: " << (typeid(fi) == typeid(Pawn)) << endl;
  20. }
  21.  
  22. void refer(figure& fi)
  23. {
  24. cout << "ref typeid check: " << (typeid(fi) == typeid(Pawn)) << endl;
  25. }
  26.  
  27. int main()
  28. {
  29. Pawn p;
  30. value(p);
  31. refer(p);
  32. }
  33.  
Success #stdin #stdout 0.01s 5432KB
stdin
Standard input is empty
stdout
val typeid check: 0
ref typeid check: 1