Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


When copy constructor can be used?

Answers were Sorted based on User's Feedback



When copy constructor can be used?..

Answer / jack

while compiler encounters following situation it uses the CC
1.when assigning one object to another object of same class
type

2.When an object is passed to the called function.....

3.when a function returns the object type and assigns it to
the another object..........

Is This Answer Correct ?    17 Yes 4 No

When copy constructor can be used?..

Answer / sachin magdum

1. "assigning" - don't use this word, it should be
initializing an object using another object of same type
2. When the object is passed to function - "by value"
3. when a function returns the object type - "by value"
here doesn't matter if you are assigning that returned
value to to another object or not.

Is This Answer Correct ?    9 Yes 4 No

When copy constructor can be used?..

Answer / vikas sood

hi fellows..try this code
class A {
public:
A() { }
A(const A& rhs)
{
cout<<"inside copy constructor..";
}
};

int main()
{
std::vector<A> aVec(10);
}

The answer to this is another reason a copy constructor
will be called.

Is This Answer Correct ?    2 Yes 1 No

When copy constructor can be used?..

Answer / priya

Whenever u want to copy the members of one object to another
object of the same class in a C++ program.

Is This Answer Correct ?    3 Yes 3 No

Post New Answer



More C++ General Interview Questions

Can I learn c++ as my first language?

0 Answers  


What is cin clear () in c++?

0 Answers  


a class that maintains a pointer to an object that is programatically accessible through the public interface is known as?

2 Answers   CTS,


What is scope resolution operator in c++ with example?

0 Answers  


Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.

0 Answers  






Write about a nested class and mention its use?

0 Answers  


Are vectors passed by reference c++?

0 Answers  


What is difference between n and endl in c++?

0 Answers  


What are punctuators in c++?

0 Answers  


What is flush c++?

0 Answers  


1)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea += sizeof(int); } return 0; } 2)#include <iostream.h> int main() { int *a, *savea, i; savea = a = (int *) malloc(4 * sizeof(int)); for (i=0; i<4; i++) *a++ = 10 * i; for (i=0; i<4; i++) { printf("%d\n", *savea); savea ++; } return 0; } The output of this two programs will be different why?

5 Answers  


What is a list c++?

0 Answers  






Categories