fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4. struct NameType : public std::string
  5. {
  6. NameType()
  7. : std::string( "foo" )
  8. {
  9. }
  10.  
  11. operator int()
  12. {
  13. return 23;
  14. }
  15. };
  16.  
  17. int main()
  18. {
  19. NameType name;
  20. std::cout << name << std::endl;
  21. std::cout << (int)name << std::endl;
  22. }
Success #stdin #stdout 0s 2856KB
stdin
Standard input is empty
stdout
foo
23