pythontutor-dev / pythontutor

10 stars 4 forks source link

'this' isn't shown when running a constructor #2

Open pgbovine opened 4 years ago

pgbovine commented 4 years ago

It'd be nice to visualize the "this" pointer when stepping through a constructor so we can see how the object gets constructed.

http://pythontutor.com/visualize.html#code=//%20From%3A%20http%3A//www.inference.phy.cam.ac.uk/teaching/comput/C%2B%2B/examples/SimpleClass.shtml%0A%23include%20%3Ciostream%3E%0Ausing%20namespace%20std%3B%0A%0Aclass%20Date%20%7B%0Apublic%3A%20%20%0A%20%20Date%28int,%20int,%20int%29%3B%0Aprivate%3A%0A%20%20int%20year%3B%0A%20%20int%20month%3B%0A%20%20int%20day%3B%0A%7D%3B%0A%0A%0Aint%20main%28%29%0A%7B%0A%20%20%20Date%20today%281,9,1999%29%3B%0A%20%20%20Date*%20pd%20%3D%20new%20Date%282,3,2007%29%3B%0A%20%20%20return%200%3B%0A%7D%0A%0A//%20LIMITATION%3A%20'this'%20isn't%20shown%20when%20running%20a%20constructor%0ADate%3A%3ADate%28int%20d,%20int%20m,%20int%20y%29%0A%7B%0A%20%20if%28d%3E0%20%26%26%20d%3C31%29%20day%20%3D%20d%3B%0A%20%20if%28m%3E0%20%26%26%20m%3C13%29%20month%20%3D%20m%3B%0A%20%20if%28y%3E0%29%20year%20%3D%20y%3B%0A%7D&cumulative=false&curInstr=5&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=cpp&rawInputLstJSON=%5B%5D&textReferences=false