Wednesday 15 February 2012

how to pass "this" in c++ -


I am confused with C ++ in the keyword this, I'm not sure if I Here's the piece of code I am struggling with:

  Class A :: Class A (Classbie) And B) {B.Denth (this); // Passing my pointer and trying to call the regularity of B, should I use "this"? } ClassB :: doSth (ClassA * a) {// do sth}  

This indicator indicates the current object instance.

class assistant {public: zero help (worker * pWorker) {// do something with TODO pWorker. . } Do something with zero help2 (worker and rWorker) {// TODO RWorker. . }}; Class worker {Public: Dowr (without) {// This takes a worker pointer, so that we can use this indicator. Helper.help (this); // To pass from context, you will have to reproduce this pointer again. Helper.help2 (* this); } Assistant Assistant; };

Also, say that you declare worker * PW = new worker () . If you call a method (Dovor) on the PW object, you will see that this

pointer and pw have the exact same value (both of them are the same address) ).

(To make sure that it produces, but I do not think it should).


No comments:

Post a Comment