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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
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
tell about copy constructor
 Question Submitted By :: Palnati
I also faced this Question!!     Rank Answer Posted By  
 
  Re: tell about copy constructor
Answer
# 1
A copy constructor is a special constructor in the C++ 
programming language used to create a new object as a copy 
of an existing object. 

There are 3 important places where a copy constructor is 
called. 

When an object is created from another object of the same 
type 
When an object is passed by value as a parameter to a 
function 
When an object is returned from a function 


 class B    //With copy constructor
      {
           private:
           char *name;
           public:
           B()
           {
           name = new char[20];
           }
           ~B()
           {
           delete name[];
           }
     //Copy constructor
           B(const B &b)
           {
           name = new char[20];
           strcpy(name, b.name);
           }
      };




 
Is This Answer Correct ?    1 Yes 0 No
Sudha
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
Why u change company? BOB-Technologies3
What is OOPS and How it is different from Procedural Programming ? HP10
tell about copy constructor Siemens1
if u write a class do u write Assignment operator and copy constructor Siemens1
difference between overloading and overridding  2
what is the difference b/w abstract and interface? Merrill-Lynch1
How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization? IntraLogic1
how do u initialize the constant variables Siemens4
How would you stop a class from class from being derived or inherited. Ness-Technologies7
What is the difference between const int *ptr and int const *ptr???  2
What is late bound function call and early bound function call? Differentiate.  2
how to swap to variables without using thrid variable in java?  3
Given two strings like x=?hello? and y=?open?, remove any character from string x which is also used in string y, thus making the result x=?hll?. IBM8
What is Method overloading?  4
can you explain how to use JavaBean in Project Infosys1
What are the main differences between procedure oriented languages and object oriented languages?  4
what is virtual function? Infosys11
when my application exe is running nad i don't want to create another exe what should i do HCL2
When is a memory allocated to a class?  3
what are the disadvantages of C++? ATS4
 
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