tell about copy constructor

Answer Posted / madhu

Basic thing, copy constructor will be called whenever a copy
is made. and copy constructors are called when:
1. create a new object using existing object.
2. When is returning to caller.
3. When an object is passed by value as a parameter to a
function

Basically a default copy constructor will be created which
does bitwise copy also know as shallow copy.
This will become a problem when we are dealing with dynamic
memory allocation for variables and leads to dangling pointer.
To overcome we have to override by deep copy.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

just right the logic of it 1--> If few people are electing then every time ur candidate should win 2--> arrange books in box, if box carry weight == books weight then take another box..... find the no of box required.

6483


What is overriding vs overloading?

580


What is the purpose of polymorphism?

675


How oops is better than procedural?

583


What is new keyword in oops?

589






What is multilevel inheritance explain with example?

623


What is encapsulation example?

545


What is the point of oop?

650


What is the difference between inheritance and polymorphism?

586


What is the difference between static polymorphism and dynamic polymorphism?

579


What is encapsulation and abstraction? How are they implemented in C++?

635


design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)

6144


What is abstraction oop?

623


2. Give the different notations for the class.\

1586


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

1696