File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ assignment. A pointer is almost always a better choice.
209
209
```c++
210
210
class ExampleClass {
211
211
public:
212
- explicit ExampleClass(int* int_ptr ) : pointer_to_integer_(int_ptr ) {}
212
+ explicit ExampleClass(OtherClass* other_ptr ) : pointer_to_other_(other_ptr ) {}
213
213
214
214
void SomeMethod(const std::string& input_param,
215
215
std::string* in_out_param); // Pointer instead of reference
@@ -230,7 +230,10 @@ class ExampleClass {
230
230
231
231
private:
232
232
std::string foo_string_;
233
- int* pointer_to_integer_; // Pointer instead of reference.
233
+ // Pointer instead of reference. If this objects 'owns' the other object,
234
+ // this should be be a `std::unique_ptr<OtherClass>`; a
235
+ // `std::shared_ptr<OtherClass>` can also be a better choice.
236
+ OtherClass* pointer_to_other_;
234
237
};
235
238
```
236
239
You can’t perform that action at this time.
0 commit comments