Skip to content

Instantly share code, notes, and snippets.

@M3nin0
Created February 10, 2020 00:26
Show Gist options
  • Save M3nin0/461d557a7cc3b6cb0e15bde0770a184c to your computer and use it in GitHub Desktop.
Save M3nin0/461d557a7cc3b6cb0e15bde0770a184c to your computer and use it in GitHub Desktop.
#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