I have a Terminallog class that overloads the <statement. If I do the following
Terminallog clog(3); clog << "stackoverflow.com is cool" << endl;
everything is working fine. "stackoverflow.com is awesome" prints beautifully on the screen, exactly what Terminallog should do.
Now i'm trying
Terminallog* clog = new Terminallog(3); clog << "stackoverflow.com is cool" << endl;
which gives me a compiler error:
error: invalid operands of types 'Terminallog*' and 'const char [5]' to binary 'operator<<'
I see that the problem is passing "<lt;" operator to a pointer, but how can I get the same behavior as with a version without a pointer? I could just dereference the pointer, but that would create a local copy of the object (which is not suitable for performance, right?)
So I wonder how to do it right?
Thank you in advance
ftiaronsem
source share