GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Programming  >  C++
Go To First  |  Previous Question  |  Next Question 
 C++  |  Question 119 of 203    Print  
How copy constructor works?

  
Total Answers and Comments: 2 Last Update: March 20, 2007     Asked by: sunil kumar dubey 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: saurabh08_chd
 
alpha a2(a1);
The compiler creates a new object a2 , and copies the data from a1 , member by member into a2. This is the default action of copy constructor

Above answer was rated as good by the following members:
yzesong
March 13, 2007 09:19:43   #1  
saurabh08_chd        

RE: How copy constructor works?
alpha a2(a1);
The compiler creates a new object a2 and copies the data from a1 member by member into a2. This is the default action of copy constructor

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
March 20, 2007 05:07:25   #2  
Raju        

RE: How copy constructor works?
Copy Constructor uses class name as reference .. it is used to declare and Initialize an object from another object. i.e It is used to create a new object from existing object of same class.
 
Is this answer useful? Yes | No

 Related Questions

Virtual destructors: If an object (with a non-virtual destructor) is destroyed explicitly by applying the delete operator to a base-class pointer to the object, the base-class destructor function (matching 
Latest Answer : Virtual constructor is not build-in C++ feature but it doesn't mean its not used by devs in code and in conversations. There are many other things that doesn't exist in particular language yet, people find ways around to solve it (SingleTon, Virtual Constructor, ...

Latest Answer : A constructor of a class is mainly responsibly for turning the raw memory allotted to an object into a usable object. DEFAULT CONSTRUCTOR:The default constructor is a constructor that takes no argument. Part::Part()String() and String(const char* str) ...
Read Answers (7) | Asked by : anil_mca

Latest Answer : Inspite of repeated requests by some (few) sensible people to everybody to read the question properly before responding, nobody listens.For doreen, the question does not ask you to explain deep copy and shallow copy mechanism neither does is asks how ...
Read Answers (3) | Asked by : suji

No 
Latest Answer : yes in c++ a class can have a default constructor.a default constructor is  a constructor which doesn't pass any arguements to it. ...
Read Answers (6) | Asked by : Nisar.E

Latest Answer : Copy constructor is 1. a constructor function with the same name as the class 2. used to make deep copy of objects. There are 3 important places where a copy constructor is called. 1. When an object is created from another object of the same type 2. When ...

Latest Answer : Constructor is called when an object is created.Copy constructor is called when the copy of an object is made. For e.g. passing parameter to function by value, function returning by value. Copy constructor takes the parameter as const reference to the ...

Latest Answer : Thank you everybody for giving the right answer to the question. However the use of the term "pointer" in the question still leaves a lingering doubt in my mind as to whether the questioner really typoed a reference as a pointer? or did ...
Tags : Pointer

What happens to the member pointers when an exception occures in constructor, while allocating memory ? how can we over come this ?
Read Answers (2) | Asked by : Shyam

Latest Answer : Virsa's questions, why constuctors cannot be private and the difference between... are not related to the original question at all, and I simply don't understand why people even take the pain of answering a separate question in the context of "how to ...
Read Answers (9) | Asked by : Test

1.why constructor can't be virtual?2.what's the difference between destuctor and virtual destructor?
Read Answers (8) | Asked by : virsa


 Sponsored Links

 
Related Articles

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

SQL Programming

SQL Programming Overview Anybody who has done something for a long time has probably wanted to change how things work at some point or another. A worker at a mill might have found a more efficient way of cutting logs, or a mathematics teacher might have had a hand in changing a school’s al
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

How WinRunner Works

WinRunner is a powerful program that will give you the ability to create tests that are highly adaptive and functional. WinRunner will function by generating a test that is based on the normal actions that a user would carry out. Some examples of these actions could be ordering a product or opening
 

WinRunner Programming Concepts

If you want to create WinRunner scripts that are highly efficient, there are important programming concepts that you will want to become familiar with. Understanding these concepts will provide you with a large number of key benefits. In addition to understanding these concepts, you must also learn
 

Programming Languages Certification

IT Certification programs have several options that will offer you the best knowledge.  By learning everything that you need to know about information technology you will be able to open new doors to your career and personal business desires.  IT Certification offers several vari
 

Neuro-linguistic Programming Methods

Neuro linguistic Programming Methods There are several methods used for performing Neuro linguistic Programming on an individual for obtaining insights into the psyche of the person in order to correct to modify certain patterns of behavior These techniques are also used for Neuro linguistic trainin
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

The Difficult Past of Neuro-linguistic programming

The Difficult Past of Neuro linguistic programming Neuro linguistic programming has had a rocky past with a number of lawsuits rivalry unsystematic development and intermittent progress During the 1980s the two founders separated after the lawsuit filed by Bandler Bandler went on to file several law
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape