Guest User

Untitled

a guest
Mar 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. printf("%s", obj) //prints "some data"
  2.  
  3. #include <cstdio>
  4.  
  5.  
  6.  
  7. class Example{
  8. public:
  9. operator int() const{
  10. return 5;
  11. }
  12. operator const char*() const{
  13. return m_text;
  14. }
  15. private:
  16. const char* m_text = "5";
  17. };
  18.  
  19. int main()
  20. {
  21. Example e;
  22. std::printf("%dn", (int)e);
  23. std::printf("%sn", (const char*)e);
  24. return 0;
  25. }
Add Comment
Please, Sign In to add comment