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                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  C++ General
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
When copy constructor can be used?
 Question Submitted By :: Shalini
I also faced this Question!!     Rank Answer Posted By  
 
  Re: When copy constructor can be used?
Answer
# 1
while compiler encounters following situation it uses the CC
1.when assigning one object to another object of same class 
type

2.When an object is passed to the called function.....

3.when a function returns the object type and assigns it to 
the another object..........
 
Is This Answer Correct ?    1 Yes 0 No
Jack
 
  Re: When copy constructor can be used?
Answer
# 2
1. "assigning" - don't use this word, it should be 
initializing an object using another object of same type
2. When the object is passed to function - "by value"
3. when a function returns the object type - "by value"
here doesn't matter if you are assigning that returned 
value to to another object or not.
 
Is This Answer Correct ?    0 Yes 1 No
Sachin Magdum
 
 
 
  Re: When copy constructor can be used?
Answer
# 3
Whenever u want to copy the members of one object to another
object of the same class in a C++ program.
 
Is This Answer Correct ?    0 Yes 0 No
Priya
 
  Re: When copy constructor can be used?
Answer
# 4
hi fellows..try this code
class A {
public:
A() { }
A(const A& rhs)
{
cout<<"inside copy constructor..";
}
};

int main()
{
std::vector<A> aVec(10);
}

The answer to this is another reason a copy constructor 
will be called.
 
Is This Answer Correct ?    0 Yes 0 No
Vikas Sood
 

 
 
 
Other C++ General Interview Questions
 
  Question Asked @ Answers
 
Can you explain the term "resource acquisition is initialization?"  1
implement stack using stack.h headerfile functions Subex1
How do I open binary files?  1
Find the second maximum in an array? HCL2
What is the Difference between "C structure" and "C++ structure"?  4
How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Lucent3
What is the difference between "overloading" and "overridding"?  3
What are the different operators in C++? HP1
Explain the ISA and HASA class relationships. How would you implement each in a class design?  2
What are advantages of C++ when comparing with C? HP3
why the size of an empty class is 1  3
What is Pure Virtual Function? Why and when it is used ? Lucent4
What is the difference between public, private, protected inheritance? Wipro4
What is problem with Runtime type identification?  1
What is "map" in STL?  1
What are the techniques you use for debugging? Adtran1
What are the different types of polymorphism?  2
class HasStatic { static int I; }; Referring to the sample code above, what is the appropriate method of defining the member variable "I", and assigning it the value 10, outside of the class declaration? a) HasStatic I = 10; b) int static I = 10; c) static I(10); d) static I = 10; e) int HasStatic::I = 10; Quark1
What compiler was used? Intel3
class Foo { const int x; protected: Foo(int f); ~Foo(); }; Foo f; Referring to the sample code above, why will the class declaration not compile? a) The variable x is const. b) The destructor is protected. c) The destructor is not public. d) The constructor is protected. e) There is no default constructor. Quark4
 
For more C++ General 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