Store a reference to an object

前端 未结 4 1327
庸人自扰
庸人自扰 2021-01-04 13:59

A bit of a weird question but I was wondering anyone could help...

In C++, I could do something like this

class MyOtherClass
{
     private:
                 


        
4条回答
  •  隐瞒了意图╮
    2021-01-04 14:44

    If the type is a reference type (which is the case for classes), then you will copy the reference, not the object itself.

    In opposition to reference type, you have value types. Values types are basically basic types : int, double, etc,

    In your case, that means that you will work with the same objects, whether you access it from the class, or from the outer calling method. It's because you are targeting the referenced object.

提交回复
热议问题