Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify C++ copy constructor vs assignment operator #37

Open
chmullig opened this issue May 6, 2014 · 2 comments
Open

clarify C++ copy constructor vs assignment operator #37

chmullig opened this issue May 6, 2014 · 2 comments

Comments

@chmullig
Copy link
Member

chmullig commented May 6, 2014

Clarify what happens in each of the situations below.

MyString s1("hello");
MyString s2(s1);
MyString s3 = s1;
MyString s4;
s4 = s1;
@kevin1
Copy link
Member

kevin1 commented Feb 29, 2016

Additionally, the example of returning a string by value should be removed because it's no longer accurate in C++11. The code would invoke std::basic_string's move constructor instead.

string call_copy(string myString) //copy constructor is called to create temporary copy of myString local to call_copy
{
    return myString; //copy constructor is called to return myString by value
}

We might be ok to remove the bad example after adding Chris's suggestion above.

@hmontero1205
Copy link
Member

WIP: #154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants