Answer Posted / amar
Copy constructors is used in following cases.
1) When object is passed by values to a fucntion
2) when function returns object by value
3) When new object is created from exixting object using
overlaoded = operator.
If user has not defined its own copy constructor, compiler
synthesised constructor would be called which will do
shallow copy. So if you have pointer in your class then only
the pointer value is copied and not the contents which
pointer points to.
| Is This Answer Correct ? | 12 Yes | 5 No |
Post New Answer View All Answers
What is the main function c++?
Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort
What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random
What is the difference between global variables and static varables?
Why the usage of pointers in C++ is not recommended ?
What is prototype for that c string function?
How to declare a function pointer?
What is a type library?
Describe the advantages of operator overloading?
what is data encapsulation in C++?
What is a driver program?
If you don’t declare a return value, what type of return value is assumed?
How to demonstrate the use of a variable?
What is the difference between the indirection operator and the address of oper-ator?
how can i access a direct (absolute, not the offset) memory
address?
here is what i tried:
wrote a program that ask's for an address from the user,
creates a FAR pointer to that adress and shows it. then the
user can increment/decrement the value in that address by
pressing p(inc+) and m(dec-).
NOW, i compiled that program and opened it twice (in 2
different windows) and gave twice the same address to it.
now look what happen - if i change the value in
one "window" of the program, it DOES NOT change in the
other! even if they point to the same address in the memory!
here is the code snippet:
//------------------------------------------------------
#include