Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Constructer initialization

Initializing variables while Writing a program is one of the most basic routines that a programmer does while writing the code. Normally it is done using the assignment operator '=' and Initializing the Variable.
E.g 

int x = 5;

// this Initializes the value of x with 5

But i found out that it could also be done this way,

int x(5); // this initializes the variable with the value 5

This is called constructor Initialization, though it is not widely used, I thought it would be a good idea to know.
Initializing the variable using this method has no advantage, so its not necessary. Just remember that it can also be done this way.


This post first appeared on Programs ++, please read the originial post: here

Share the post

Constructer initialization

×

Subscribe to Programs ++

Get updates delivered right to your inbox!

Thank you for your subscription

×