When we create a class or struct, its constructor is called. Constructor will have same name as a class or struct and is usually used to initialize the data members of the new object. There are three types of constructors:
Instance constructors are used to create and initialize any instance member variables when we use new expression to create an object of a class.
Static constructors are used to initialize static data or to perform actions that need to be performed only once. It is called automatically before first instance is created or any of the static members are referenced.
Private constructors are only used when a class contains only static members.
Subscribe to:
Post Comments (Atom)
Call a function in child component from parent component in React
Consider the following parent component class Parent extends React.Component { constructor(props) { super(props); thi...
-
Open visual studio developer command prompt. Start your service and make sure it is up and running. Copy the URL of service . In visual...
-
The process of replacing a module with generic and mostly empty object, called a mock. Advantages: Isolates our code from its dependen...
No comments:
Post a Comment