Hi, I have a question:
I need to use variable imm within member draw(). How can I do?Code:
class DOOR { public: ........ draw(); }
Thanks
Printable View
Hi, I have a question:
I need to use variable imm within member draw(). How can I do?Code:
class DOOR { public: ........ draw(); }
Thanks
What calls that DOOR::draw() method? Maybe you invoke it only from build class?
Code:
void DOOR::draw() { imm="hello\n"; }
I'd like use imm in ::draw () and I'd like can use "only" imm and not other variables of Build class.....
But where do you intend to use thet DOOR::draw() method?Quote:
Originally Posted by mickey
now I don't know.
I'd like use imm within Door:draw() and compile it.
Thanks.
So maybe you should redesign your classes?Quote:
Originally Posted by mickey
For example like this:Other possibility is that each of DOOR instances would hold a pointer or reference to a build instance:Code:
void DOOR::draw( const QImage& img ) { // ... } void build::draw() { // ... for( std::vector<DOOR>::iterator it = door.begin(); it != door.end(); ++it ) { it->draw( imm ); } // ... }
Everything depends on the way you want to use those two classes and on things what they represent.Code:
void DOOR::draw() { // ... // ... } const QImage& build::image() const { return _imm; }
OK thanks. But why do you use underscore symbol?
In this case is just a habit.Quote:
Originally Posted by mickey
In my code I add underscore to member variables to distinguish them from parameters.