Reputation: 1179
I am reading C++ Primer and this piece of code confuses me a little. Maybe i have read before but forgotten what its about.
this code has 2 copy constructors but i dont know what the difference is between them
class Quote {
public:
Quote() = default;
Quote(const Quote&) = default; // <<== this one
Quote(Quote&&) = default; // <<== and this one
Quote& operator=(const Quote&) = default;
Quote& operator=(Quote&&) = default;
virtual ~Quote() = default;
}
what is the difference in general?
and what do the double "&" mean?
Upvotes: 0
Views: 85
Reputation: 6866
They are not both copy constructors, only the first one: Quote(const Quote&) = default;
. The second one is a move constructor, do some reading on move semantics and C++11.
Upvotes: 4