6 ms·
I've never done any real development with a language that uses pointers. So noob question: why would one use a pointer over passing a variable? (those are the t
by neals 9y ago
I've never done any real development with a language that uses pointers. So noob question: why would one use a pointer over passing a variable? (those are the two flavors right?)
- andrepd 9y agoThat's far too big a question to answer here, but consider for example writing a function thst modifies its arguments.
- em3rgent0rdr 9y agoWhen passing a pointer, if you want the resulting state of the variable, the function doesn't need to return a value. Also if the variable is a large object, then passing just a pointer to it saves time spent copying the object.
- Koshkin 9y agoI am sure parent meant "passing by reference". (In Oberon, for example, this is indicated by the VAR keyword.)
- mirekrusin 9y agoThere's absolutely no reason to use pointers, unmentioned detail is that c++20 will bundle v8's garbage collector in the runtime to support this removal.
- tomsmeding 9y agoThat's horrifying. And what's even more interesting is that C++11 even had a proposal for garbage collection, even if no-one implemented it.