Hello, everyone.
I'm curious. Why can't I overload an operator only with pointers to
class objects?
For instance:
class SomeClass {
friend SomeClass *operator<<(Som eClass *, int);
};
This code will give me the following error message in G++:
error: 'SomeClass* operator>>(Some Class*, int)' must have an
argument of class or enumerated type
However, if I use references instead of pointers, the code will compile
fine. I'd like to know the reason behind that restriction.
Thanks!
Rg
I'm curious. Why can't I overload an operator only with pointers to
class objects?
For instance:
class SomeClass {
friend SomeClass *operator<<(Som eClass *, int);
};
This code will give me the following error message in G++:
error: 'SomeClass* operator>>(Some Class*, int)' must have an
argument of class or enumerated type
However, if I use references instead of pointers, the code will compile
fine. I'd like to know the reason behind that restriction.
Thanks!
Rg
Comment