how can I make a class return a value without a function?
if I make this class for example:
#include<iostream>
#include<sstream>
using namespace std;
class item{
private:
string name;
int quantity;
public:
string ImAFunction(){
stringstream ss;
ss << quantity << ' ' << name;
string result;
ss >> result;
return result;
}
};
then I'll do this whenever I want to print it
cout<<obj.ImAFunction();
but I want it to be like this
cout<<obj;
I hope I'm clear and not annoying