SV-- declaration and instantiation

 

 

1. class constructor ---- new

SV in the past by the new constructor to create an object , the process of creating an object, you can do some initialization work.

new function does not return a value, his return type is the type of assignment expression of value left.

If you do not define their own new function, the SV will call the default new function; a derived class of the new function will first call the parent class of new functions.

 

2. super

  Of The Super keyword Used IS WITHIN A derived from class to REFER to Members, class Parameters value, or local value of Parameters The Base class (Super keyword is used to reference a member of the parent class, parameters, etc.). It IS Necessary to use Super to of a base class when those are overridden by the derived class ( if the parent class members, subclasses override parameters, and want to use the subclass overloads before access members, value parameters, or local value parameters of members of the parent class, then use super).

But only with a layer of super, if super.super.new () this way, no.

  A super.new call shall be the first statement executed in the constructor. This is because the superclass shall be initialized before the current class and, if the user code does not provide an initialization, the compiler shall insert a call to super.new automatically. super.new()会对父类中定义的成员初始化。

 

3. Declare and instantiate

Declaration is to declare a variable, which holds the handle class object.

Instantiated by the constructor, create an object, allocate memory space, and will handle the statement points to this memory space.

Although SV can instantiate the object when it was declared, but this is not recommended. Generally outside the object class declaration block statement, embodiment of objects within a block statement; control sequence may be instantiated objects.

 

4. Object release

Assigned when the object is created in the SV automatically manage the memory. SV remembers the number of points for a memory handle, if a piece of memory is not a handle to it, then it will be automatically released.

 

 

Guess you like

Origin www.cnblogs.com/east1203/p/11598033.html