I have a class named W_debug. I want to use it at my_oher_class.
I declare it at my_other_class.h
W_debug w_debug;
W_debug w_debug;
To copy to clipboard, switch view to plain text mode
and / or ( To try if it runs...)
W_debug *w_debug
W_debug *w_debug
To copy to clipboard, switch view to plain text mode
;
But the line :
w_debug<<"hello"<<"how areyou";
w_debug<<"hello"<<"how areyou";
To copy to clipboard, switch view to plain text mode
Does not work, compiler gives me the error :
passing 'const W_debug' as 'this' argument of 'W_debug& W_debug:
perator<<(const char*)' discards qualifiers
This is my code :
(It works fine if I use it using W_debug()<< , that is to say : without create the instance)
class W_debug
{
public:
W_debug();
~W_debug();
W_debug & operator + (int data);
W_debug & operator + (const char data);
W_debug & operator + (const char * data);
W_debug & operator + (double data);
.....
class W_debug
{
public:
W_debug();
~W_debug();
W_debug & operator + (int data);
W_debug & operator + (const char data);
W_debug & operator + (const char * data);
W_debug & operator + (double data);
.....
To copy to clipboard, switch view to plain text mode
And :
W_debug::W_debug() { }
W_debug::~W_debug(){ }
W_debug& W_debug::operator << (const char * data) {
os<<data;
return *this;
......
}
W_debug::W_debug() { }
W_debug::~W_debug(){ }
W_debug& W_debug::operator << (const char * data) {
os<<data;
return *this;
......
}
To copy to clipboard, switch view to plain text mode
PS:
I can do something like what I want with 'w_debug' with stringstream :
stringstream os;
os <<data1<<data2;
stringstream os;
os <<data1<<data2;
To copy to clipboard, switch view to plain text mode
I want to do something similar
Any help ? Thanks
Bookmarks