Store a reference to an object

前端 未结 4 1344
庸人自扰
庸人自扰 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:43

    You're mixing things up. In C#, assignment statements such as

        logger = _logger;
    

    copy references, not objects. After this statement executes, there is still (at most) only one MyLogger - it's now referred to by two object variables.

提交回复
热议问题