<pre>
someclass& operator <<(char *string)
{
...
}
someclass *object = new someclass;
object << "hello"; // error
// now when i want to use that, it should be this way,
*object << "hello";
</pre>
overloading the insertion (<<) operator, problem when using it,
hiya,
but i wouldn''t like it to be that way, ie, *object << "...";
so is there any other way around this?
thanks,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
someclass object;
object << "hello";
?
object << "hello";
?
---visit #directxdev on afternet <- not just for directx, despite the name
er, no, i would like to declare that object as a pointer,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
I don''t really see the problem. You want to do an operation on something that is pointed to, so you have to use *.
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
If you overload a free-standing binary operator, then one of the arguments must be of user-defined type. If you code this:
Then both operands are of pointer type, so it is not possible to overload.
someclass *object = new someclass;object << "hello";
Then both operands are of pointer type, so it is not possible to overload.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement