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

what are the iterator and generic algorithms.

1989


Is c++ the best programming language?

1076


Explain deep copy and a shallow copy?

1115


Is c++ a programming language?

1137


What is the main purpose of overloading operators?

1206


What is class in c++ with example?

1367


How is computer programming useful in real life?

1114


How can you differentiate between inheritance and implementation in c++?

1269


What is a class template?

1132


an operation between an integer and real always yeilds a) integer result b) real result c) float result

1213


What is a breakpoint?

1073


How can I learn dev c++ programming?

1104


Is it possible to get the source code back from binary file?

1429


What are maps in c++?

1004


the first character in the variable name must be an a) special symbol b) number c) alphabet

1150