Tuesday, 31 December 2013

Filled Under:

Initialization of variables

Initialization of variables:

                                              When declaring a variable, its value is by default undetermined. But you may want a variable to store a determined value when you declared it. In order to do that, you can initialize the variable. There are two ways to do this in C++:

 1-First way like c:

   Syntax:
                                 Data type variable name = initialize value;

 For example:

      Int a = 0;
     Float pi=3.4;

 2-other way initialize a variable called constructor initialization:

Syntax:
                   Data type variable name(initialize value);

For example:

                           Int a(0);
                           Float pi(3.4);




0 comments:

Post a Comment