2021年1月17日星期日

C++ Stack Frame/Activation Record and 'this' pointer

This is my first post here, if I am messing something up I would appreciate any advice. Does C++ implement an activation record? My experience with this has been largely with Java so I am unsure if it is the same for other languages. If so, in C++ is it correct to say that 'this' is a pointer to the previous record on the activation stack? For example:

...  class Example {  private:      int num;  public:      void setNum(int num) {          this->num = num;      }  ...  

So the activation stack would have an 'Example' object on the stack and then when the function 'setNum(...)' is called it would put that call on the activation stack. So 'this' would be of type Example* and would point to the 'Example' object that is on the stack before the function call. Is that correct? Thanks all!

https://stackoverflow.com/questions/65768972/c-stack-frame-activation-record-and-this-pointer January 18, 2021 at 12:49PM

没有评论:

发表评论