纠正我的困惑 [英] Rectify my confusion

查看:61
本文介绍了纠正我的困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设计模式–控制反转和依赖注入 [^ ]

很抱歉,这是一个愚蠢的问题

在构造函数方法论段落中...有

Design pattern – Inversion of control and Dependency injection[^]

I am sorry if it is silly question

in the constructor methodology paragraph ...there is

public class clscustomer
{
 private Iaddress _address;
  public clscustomer(Iaddress obj);
      {
          _address=obj;
      }

..........
}


我认为Iaddress _address;和Iaddress obj相同吗?它们之间有什么区别?


I think Iaddress _address; and Iaddress obj are same ?what is the difference between them?

推荐答案

构造函数用于设置在类外部不可见的私有变量.参数obj的有效范围仅是构造函数.

是的,成功调用构造函数后,私有字段应包含相同的对象.
The constructor is used to set the private variable which isn''t visible outside the class. Valid scope for the parameter obj is only the constructor.

Yes, after succesfully calling the constructor the private field should contain the same object.


这篇关于纠正我的困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆