kiker99
4th May 2006, 21:56
Hello,
i'm sure someone had the same problem before. I am trying to make one of my classes able to receive "<<"-Operations. this is my code:
// messagepipe.h
friend void operator<<(MessagePipe *pipe, QString string);
//messagepipe.cpp
void operator<<(MessagePipe *pipe, QString string)
{
//do something
}
MessagePipe is my class. This produces an error if used like this:
MessagePipe *hint;
hint << "Hi there.";
--> error: invalid operands of types 'MessagePipe*' and 'const char [10]' to binary 'operator<<'
Hm, he isn't able to get a QString out of "Hi there". This seems to work only if used as a real parameter. Does anybody understand this behaviour? I don't want to write everytime QString("My Text"). Any ideas? Thanks.
i'm sure someone had the same problem before. I am trying to make one of my classes able to receive "<<"-Operations. this is my code:
// messagepipe.h
friend void operator<<(MessagePipe *pipe, QString string);
//messagepipe.cpp
void operator<<(MessagePipe *pipe, QString string)
{
//do something
}
MessagePipe is my class. This produces an error if used like this:
MessagePipe *hint;
hint << "Hi there.";
--> error: invalid operands of types 'MessagePipe*' and 'const char [10]' to binary 'operator<<'
Hm, he isn't able to get a QString out of "Hi there". This seems to work only if used as a real parameter. Does anybody understand this behaviour? I don't want to write everytime QString("My Text"). Any ideas? Thanks.