-
Notifications
You must be signed in to change notification settings - Fork 0
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
Discourage use of References #5
Comments
Can you specify what kind of errors? I'm of the opinion that we should actually be encouraging usage of references, especially |
The error happens if people assume value semantics while the code has pointer semantics. |
@mkristien in that example, the real problem is that the singleton pattern for the |
I don't think references are confusing as they are the closest thing C++ has to languages like Java or Python which only have one way of passing things around. Hence most programmers should be more skilled at working with references than working with pointers/values. If there is evidence that people were actually messing up with references much more often than with values and pointers, I'll change my opinion. |
void foo(int& val);
orvoid foo(int* val);
?I do not like references because they look like passing values around but they behave like pointers. This can lead to programmers' errors.
The text was updated successfully, but these errors were encountered: