What is the difference between “instantiated” and “initialized”?

后端 未结 11 2280
青春惊慌失措
青春惊慌失措 2020-11-30 17:02

I\'ve been hearing these two words used in Microsoft tutorials for VB.NET. What is the difference between these two words when used in reference to variables?

11条回答
  •  误落风尘
    2020-11-30 17:47

    We can see it this way. For a line of code below:

    var p = new Person();
    

    The above line can be read as following two ways:

    1. The variable p has been initialized as a person class
    2. Person class has been instantiated in variable p

    The subject of reference or context matters. When talking in terms of variable, we use the word initialize. When talking in terms of class/type, we use the word instantiate.

提交回复
热议问题