Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocxs committed Mar 13, 2015
1 parent c0f0b27 commit 4493cd1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ch07/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ Both are noting happened.

```cpp
(a) Sales_data &combine(Sales_data); // ok
(b) Sales_data &combine(Sales_data&); // [Error] no matching function for call to 'Sales_data::combine(std::string&)' (`std::string&` can not convert to `Sales_data` type.)
(b) Sales_data &combine(Sales_data&); // [Error] no matching function for call to 'Sales_data::combine(std::string&)' (`std::string&` can not convert to `Sales_data` type.)
//It's wrong. Because combine’s parameter is a non-const reference , we can't pass a temporary to that parameter. If combine’s parameter is a reference to const , we can pass a temporary to that parameter. Like this :Sales_data &combine(const Sales_data&); Here we call the Sales_data combine member function with a string argument. This call is perfectly legal; the compiler
automatically creates a Sales_data object from the given string. That newly generated (temporary) Sales_data is passed to
combine.
(c) Sales_data &combine(const Sales_data&) const; // [Error] assignment of member 'Sales_data::units_sold' in read-only object. (we cannot combine the other `Sales_data` object.)
```
Expand Down

0 comments on commit 4493cd1

Please sign in to comment.