Skip to content

Commit

Permalink
fixup! squash! doc: formalize non-const reference usage in C++ style …
Browse files Browse the repository at this point in the history
…guide
  • Loading branch information
addaleax committed Oct 1, 2018
1 parent 8daa18e commit e9f8406
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CPP_STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ assignment. A pointer is almost always a better choice.
```c++
class ExampleClass {
public:
explicit ExampleClass(int* int_ptr) : pointer_to_integer_(int_ptr) {}
explicit ExampleClass(OtherClass* other_ptr) : pointer_to_other_(other_ptr) {}
void SomeMethod(const std::string& input_param,
std::string* in_out_param); // Pointer instead of reference
Expand All @@ -230,7 +230,10 @@ class ExampleClass {
private:
std::string foo_string_;
int* pointer_to_integer_; // Pointer instead of reference.
// Pointer instead of reference. If this objects 'owns' the other object,
// this should be be a `std::unique_ptr<OtherClass>`; a
// `std::shared_ptr<OtherClass>` can also be a better choice.
OtherClass* pointer_to_other_;
};
```

Expand Down

0 comments on commit e9f8406

Please sign in to comment.