php hit counter

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the syntax of copy constructor in c 2011
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1
What is the syntax of copy constructor. Describe each and every thing in detail in it.

How can we declare and define copy constructor.
Reply
#2
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
A variable is declared which is initialized from another object, eg,

· Person q("Mickey"); // constructor is used to build q.
· Person r(p); // copy constructor is used to build r.
· Person p = q; // copy constructor is used to initialize in declaration.
· p = q; // Assignment operator, no constructor or copy constructor.
A value parameter is initialized from its corresponding argument.
f(p); // copy constructor initializes formal value parameter.

An object is returned by a function.
C++ calls a copy constructor to make a copy of an object in each of the above cases. If there is no copy constructor defined for the class, C++ uses the default copy constructor which copies each field, ie, makes a shallow copy.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  array project code c++ 2011 Vuhelper 0 1,363 12-10-2011, 06:32 PM
Last Post: Vuhelper
  factorial in C++ code 2011 Vuhelper 0 1,030 12-10-2011, 06:31 PM
Last Post: Vuhelper
  Is constructor necessory in c++? And if than why? Vuhelper 0 1,980 11-05-2011, 05:12 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,115 11-05-2011, 05:05 PM
Last Post: Vuhelper
  What is the Thing Queue? in c++ 2011 Vuhelper 0 1,870 11-05-2011, 05:02 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,810 11-05-2011, 05:01 PM
Last Post: Vuhelper
  How to write a summation in a sequence? C++ 2011-12 Vuhelper 2 1,475 09-19-2011, 04:53 AM
Last Post: Xpert
  GetPixel problem in c++ 2011-12 Vuhelper 0 2,584 09-18-2011, 07:12 PM
Last Post: Vuhelper
  C++ with loop code 2011-12 Vuhelper 0 1,062 09-18-2011, 07:09 PM
Last Post: Vuhelper
  how can i read the last letter of a input file? 2011 Vuhelper 0 1,907 09-12-2011, 10:24 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support