Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- printf("%s", obj) //prints "some data"
- #include <cstdio>
- class Example{
- public:
- operator int() const{
- return 5;
- }
- operator const char*() const{
- return m_text;
- }
- private:
- const char* m_text = "5";
- };
- int main()
- {
- Example e;
- std::printf("%dn", (int)e);
- std::printf("%sn", (const char*)e);
- return 0;
- }
Add Comment
Please, Sign In to add comment