mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Small typo
This commit is contained in:
parent
9d04832ca2
commit
7c68566196
|
@ -607,7 +607,7 @@ We can of course pass the number of elements along with the pointer:
|
||||||
f2(new int[n], m); // bad: the wrong number of elements can be passed to f()
|
f2(new int[n], m); // bad: the wrong number of elements can be passed to f()
|
||||||
}
|
}
|
||||||
|
|
||||||
Passing the number of elements as an argument is better (and far more common) that just passing the pointer and relying on some (unstated) convention for knowing or discovering the number of elements. However (as shown), a simple typo can introduce a serious error. The connection between the two arguments of `f2()` is conventional, rather than explicit.
|
Passing the number of elements as an argument is better (and far more common) than just passing the pointer and relying on some (unstated) convention for knowing or discovering the number of elements. However (as shown), a simple typo can introduce a serious error. The connection between the two arguments of `f2()` is conventional, rather than explicit.
|
||||||
|
|
||||||
Also, it is implicit that `f2()` is supposed to `delete` its argument (or did the caller make a second mistake?).
|
Also, it is implicit that `f2()` is supposed to `delete` its argument (or did the caller make a second mistake?).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user