Home » Ask & Discuss » Board Exams - CBSE, ICSE, State Boards » Computer Science « Back to Discussion



Computer Science

Chuck Norris's Avatar
Scorching goIITian

Joined: 25 Nov 2008
Post: 210
23 Mar 2009 20:26:34 IST
0 People liked this
1
382 View Post
comp
None

How many times is the copy constructor invoked in the following code? Mention when it is invoked also.
Trial func(Trial u)
{
Trial v(u);
Trial w=v;
return w;
}
void main()
{
Trial x;
2
19
Trial y=func(x);
Trial z=func(y);
}


Share this article on:

Comments (1)

kabi's Avatar

Blazing goIITian

Joined: 11 Jan 2009
Posts: 575
23 Mar 2009 20:36:53 IST
1 people liked this

two times func() is called

each time it is called 4 times copy constructors .

that r ::

1 . when d parameter is passed by value by u .

2. when v is initialized.

3. when w is initialized.

4.when w is returned .

so total 8 times .

Sorry i couldn't give d answer of ur other's question. Half of sys still left.

Thank u and All the best.




Quick Reply


Reply

Some HTML allowed.
Keep your comments above the belt or risk having them deleted.
Signup for a avatar to have your pictures show up by your comment
If Members see a thread that violates the Posting Rules, bring it to the attention of the Moderator Team
Free Sign Up!

Preparing for IIT-JEE ?

Arihant Revision Package for IIT JEE - Books, Practice Tests + Rank Predictor


@ INR 1,995/-

For Quick Info

Name

Mobile No.

Find Posts by Topics

Physics.

Topics

Mathematics.

Chemistry.

Biology

Parents

Board

Fun Zone

Sponsored Ads