ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
Why a "operator=(...)" when there is a copy ctor?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Why a "operator=(...)" when there is a copy ctor?
Answer
# 1
You use the assignment operator (operator = ()) whenever an
existing object is to be replaced with a different object.
The copy constructor X(const X&) is used to create a new
instance of an X-object exactly like another.

Notice the subtle difference. Assignment changes an existing
object while construction creates a new object. You can view
assignment as the application of a destructor, to flush away
the existing object, followed by a copy construction, to
make an exact copy of the assigned object.
 
Is This Answer Correct ?    0 Yes 0 No
Guest
 
  Re: Why a "operator=(...)" when there is a copy ctor?
Answer
# 2
Copy Constructor means creation of new object and after that
copy properties of some exiting object to newly created object.

Overloading assignment operator is that copy properties of
some exiting object to another exiting object of same type.
 
Is This Answer Correct ?    0 Yes 0 No
Arun
 
 
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
how do u initialize the constant variables Siemens4
What do you mean by inline function?  1
what is the use of mutable key word HCL2
What is namespace?  6
features of OOPS Ness-Technologies5
what is the function of 'this' operator ?  5
what is the need of abstraction? what is abstraction?what is the abstraction for stack? Verizon5
what is a ststic variable and stiticfunction briefly explain with exmple and in which case we use HCL1
What is virtual constructors/destructors?  3
What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<<v(); } 1) 1 2) 0 3) Code cannot compile  3
When is an object created and what is its lifetime? IBM1
write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floating point values.  1
polymorphism means? BFL2
What is a scope resolution operator? HP4
Why do we use virtual functions?  3
how to create thread in java? Infosys10
pointers are support in C#? if yes then how to use it? Softvision-Solution5
How is exception handling carried out in c++?  1
what is the main difference between c and c++? Microsoft27
In what situation factory design patterns,DAO design patterns,singleton design patterns should be applied.?  1
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com