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 difference between initialization and assignment?

Answer Posted / jaroosh

Those answers are actually highly insufficient.
Here are some differences to point that come to my mind :
a) you CANT assign to a const variable, whereas you CAN
initialize it. For example :
const AXC d = 3; //OK! initialization
d = 3; //WRONG! cannot assign to const
b) initialization IS about creating object
assignment IS about setting some value to object
This is why in the following code :
AXC d = 3;
AXC x;
x = 2;
first line will require an appropriate constructor:
AXC(int i) { ... }
whereas the third line will use overloaded assignment "="
operator if its specified (if not, it will use constructor
like above):
AXC operator =(int x) { ... }
c) Initialization also calls copy constructors, while
assignment does not :
A c;
A d = c; //Calls copy constructor of A
A e;
e = c; //Calls assignment operator of A

Is This Answer Correct ?    71 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are stacks?

1028


Is it possible to have a recursive inline function in c++?

1000


Explain 'this' pointer and what would happen if a pointer is deleted twice?

1038


How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?

1051


Write my own zero-argument manipulator that should work same as hex?

1013


Is facebook written in c++?

973


Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

966


Discuss the possibilities related to the termination of a program before entering the mainq method?

920


What is runtime polymorphism in c++?

1124


Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.

1036


If all is successful, what should main return a) 0 b) 1 c) void

991


What is virtual destructor ans explain its use?

1098


What ANSI C++ function clears the screen a) clrscr() b) clear() c) Its not defined by the ANSI C++ standard

1003


What does catch(…) mean?

1087


Where the memory to the static variables is allocated?

1024