I was some misunderstanding about default operator definition(by compiler).
I have small class:
class Q
{
public:
Q() {};
Q(int i) { x = i; };
~Q() {};
void print() { cout << x << endl; };
Q& operator * ()
{
cout << "operator *\n";
return *this;
};
const Q& operator * () const
{
cout << "operator *\n";
return *this;
};
private:
int x;
};
And i'm doing this whit it:
int main()
{
Q* obj_p = new Q(1);
Q obj = *obj_p;
obj.print();
return 0;
}
I expected to see operator *, before 1. But I saw only print() method result.
What does it mean? That I don't need to overload operator * - it's compiler work or that I do overloading somehow wrong?
Thanks.