When copy constructor can be used?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a static element?

784


Define 'std'.

875


What are c++ manipulators?

795


what is multi-threading in C++?

775


Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---

1849






What are virtual functions in c++?

871


Difference between pointer to constant vs. Pointer constant

793


Which programming language is best?

738


How do you clear a set in c++?

792


can any one help to find a specific string between html tags which is changed to a sting.. weather.html looks (for location) is somewhere #include #include #include using namespace std; string find_field(string myPage,string); int main (void) { string page, line, location, temperature; ifstream inputFile("weather.xml"); while(getline(inputFile, line)) { page.append(line); line.erase(); } // Now page is a string that contains the whole xml page // Here you need to write something that finds and // extracts location and temperature from the XML // data in the string page and stores them in // the strings location and temperature respectively location=find_field(page,"location"); temperature=find_field(page,"temp_c"); cout << "Location: "<

1829


What is the last index number in an array of 100 characters a) 100 b) 99 c) 101

816


What is functions syntax in c++?

797


What is the difference between strcpy() and strncpy()?

825


Can a constructor return a value?

840


What is extern c++?

701