answersLogoWhite

0

Initialization lists makes a difference when we have objects as members. Instead of using default initialization followed by assignment, the initialization list can initialize the object to its final value. This can actually be noticeably faster.

When you need to initialize constant member, references and pass parameters to base class constructors, initialization list is the only choice. if you have members of class type with no default constructor available, initialization is the only way to construct your class.

There is only one way to initialize base class instances and non-static member variables and that is using the initializer list.

If you don't specify a base or non-static member variable in your constructor's initializer list then that member or base will either be default-initialized (if the member/base is a non-POD class type or array of non-POD class types) or left uninitialized otherwise.

Once the constructor body is entered, all bases or members will have been initialized or left uninitialized (i.e. they will have an indeterminate value). There is no opportunity in the constructor body to influence how they should be initialized.

You may be able to assign new values to members in the constructor body but it is not possible to assign to const members or members of class type which have been made non-assignable and it is not possible to rebind references.

For built in types and some user-defined types, assigning in the constructor body may have exactly the same effect as initializing with the same value in the initializer list.

If you fail to name a member or base in an initializer list and that entity is a reference, has class type with no accessible user-declared default constructor, is const qualified and has POD type or is a POD class type or array of POD class type containing a const qualified member (directly or indirectly) then the program is ill-formed.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is the order of initialization of data in C plus plus?

The general order of initialization is:Base class objects (if present)Member data objectsConstructor function code


Initialization of variables in namespace in C plus plus?

Is an important thing to do.


What is message passing in c plus plus?

-define class with necessary data member & member function. -create object of that class. -communication.


What is the difference between instantiation and initialization in C plus plus?

Instantiation is creating the instance of the variable/object . While Initialization is to provide the variable with some value. int i; // i is an instance of an integer i=10; //initialised with the value 10


What do you mean by initialization in c plus plus?

Not initialized variable: int myInt; Initialized variable: int myInt = 10;


How do you avoid garbage values in c plus plus programs?

Initialization. Hint: your compiler might warn you, neverignore warnings if you aren't absolutely sure what they mean.


What do you mean by initialisation of objects in c plus plus?

Initialization of objects means to provide an initial value for the object. This is usually done by the constructor, or it can be done with an assignment statement.


Is a paladin a member?

yes paladin is member, sadly plus you need rank10 warroior and healer and its member :(


What is member fusion in c plus plus?

If you are asking about member functions. When we declare a function inside a class then that function becomes member function of that class and this function can access the whole class


What is the difference between an attribute and a behavior in c plus plus?

An attribute is a class member variable while a behaviour is a class member method.


Can you use string in list container in c plus plus?

Yes. Since the list container is templatized, you can use whatever type of object you want as the contained list.


Is it necessary to know c and c plus plus to learn java?

Of course not.