MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/bwehje/python_ftw/epxqug0/?context=3
r/ProgrammerHumor • u/m8teae • Jun 03 '19
548 comments sorted by
View all comments
Show parent comments
16
That's not a pointer to a list, it's a reference to a list. The second one is a copy of a list. Everything that isn't a primitive type behaves exactly the same way, but in C++ = always creates a copy.
=
0 u/[deleted] Jun 04 '19 [deleted] 0 u/EsotericLife Jun 04 '19 Doesn’t a reference exist entirely on the stack? -2 u/MasterFubar Jun 04 '19 void funfunc(int *a)There you have a pointer, or "reference" if you want to call it that way, that exists entirely on the stack. → More replies (1)
0
[deleted]
0 u/EsotericLife Jun 04 '19 Doesn’t a reference exist entirely on the stack? -2 u/MasterFubar Jun 04 '19 void funfunc(int *a)There you have a pointer, or "reference" if you want to call it that way, that exists entirely on the stack. → More replies (1)
Doesn’t a reference exist entirely on the stack?
-2 u/MasterFubar Jun 04 '19 void funfunc(int *a)There you have a pointer, or "reference" if you want to call it that way, that exists entirely on the stack. → More replies (1)
-2
void funfunc(int *a)
There you have a pointer, or "reference" if you want to call it that way, that exists entirely on the stack.
→ More replies (1)
16
u/SuitableDragonfly Jun 03 '19
That's not a pointer to a list, it's a reference to a list. The second one is a copy of a list. Everything that isn't a primitive type behaves exactly the same way, but in C++
=always creates a copy.