this keyword and Self References in oop and c++
What is 'this'?
- 'this' is a keyword that refers to the current instance of the class.
- It can be used to refer to the current class instance variable.
- ‘this’ to pass a current object as a parameter to another method.
- 'this' is a pointer of the current object.
- This is a hidden object of the current class.
Self References
When functions are set up to not return any values, like in this case, where f1(), f2(), and f3() were designed, it can be helpful to make them return a reference to the object they're updating. This way, you can chain these functions together in a single line of code, making it easier to perform multiple operations one after the other.
Post a Comment