I'm working with QT and I created my custom class (MyClass) as Singleton.
//MyClass.cpp
MyClass(){}
MyClass* MyClass::getInstance()
{
if(!instance)
instance = new MyClass();
return instance;
}
//MyClass.h
public:
static MyClass* getInstance();
private:
MyClass();
static MyClass* instance;
Now I need to overload operator "<<" for it, so i could call it like this in code:
MyClass::getInstance()<<( QString("Tekst") );
But after many attempts - I can't get how should I do it. I tried in many ways but i still only can get either - incorrect declaration errors (in MyClass.h) or
no match for 'operator<<' (operand types are 'MyClass*' and 'QString')
for line:
MyClass::getInstance()<<( QString("Tekst") );
EDIT 1
Basicly, i want to use this class to save those QStrings. It shoud be similar to QDebug, but i got my specified "place" to save it - still, way to input data shoud be the same (with <<).
EDIT 2
Sicne few ppl were argueing i didnt een try to code this - here are few of my attempts (just declarations):
MyClass &operator<<(QString qds);
//----
MyClass* & operator<<(QString text);
//----
void operator<<(QString rhs);
//----
MyClass* operator<<(QString rhs);
//----
friend QString &operator<<(QString &input, const MyClass &mc );
//----
MyClass & operator<<(MyClass& out, const QString& text);