Created
February 10, 2020 00:26
-
-
Save M3nin0/461d557a7cc3b6cb0e15bde0770a184c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// Idea from: https://stackoverflow.com/questions/5171739/tostring-override-in-c | |
class Teste | |
{ | |
private: | |
int a; | |
public: | |
Teste(int a) | |
{ | |
this->a = a; | |
} | |
operator std::string() const | |
{ | |
return "Olha o valor"; | |
} | |
}; | |
int main() | |
{ | |
Teste teste(12); | |
std::cout << std::string(teste) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment