Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is the order of initialization for data?

Answer Posted / kasi

1) Brief details on initialization:

To perform true initialization (not assignments) for a
class data member, C++ provides extened syntax for
constructor function.

Syntax:
class A
{
int ssn;
double sal;
public:
A(int j,double k):sal(k),ssn(j) //initialization
{
//assignement
}
}

Therefore constructor function has 2 parts they are
- initialization
- Assignment
Note - initialization will be excuted first and then
assignment

2) When is the initialization list mandatory?
- If the instance variable is constant
- If the class contains reference variable

3) coming to the posted question: order of member
initialization will be done in 2 ways by the compiler.

A) Declaration order
B) The order of members in the intialization list.

For the above example ssn is initialized first then sal.

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how to initialize a const member data.

979


How we can differentiate between a pre and post increment operators during overloading?

1041


Explain object slicing in c++?

1009


Is java made in c++?

1000


Mention the ways in which parameterized can be invoked.

889


How would you obtain segment and offset addresses from a far address of a memory location?

1026


How many types of modularization are there in c++?

1021


what is a class? Explain with an example.

1096


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create

2577


How would perform Pattern Matching in C++?

1168


What is == in programming?

972


What's the best free c++ profiler for windows?

1031


What are c++ stream classes?

985


Difference between pass by value and pass by reference?

1082


What is code reusability in c++?

1180