I’m new at C++ and I am missing some terminology (couldn’t ask a specific question to Google), so I’ll try to be as clear as possible.
Let’s say I have instantiated an object of class A. Then say, from a method of this object of class A, I create an object of class B.
In my class B, i want to use the object of class A as an argument (passed by reference if possible).
Is that possible?
Thanks.
Yes, in your method of
class Ayou can reference the current instance ofAusing the keywordthis. For example, you can providethisforclass Ato the constructor ofclass B.My C++ syntax is a bit rusty, so here’s a C# example that can be translated fairly literally to C++: