E0005: ArrayList.get() returns a pointer, not a value

Compiler Error

What it means

ArrayList<UserType> stores objects as pointers (T*) internally, which matches Java's reference semantics at the C++ level. That means .get() hands back a T*, not a copy of the object. Trying to assign it directly to a T variable won't compile because you can't copy a pointer into a plain object.

How to fix it

Declare the variable as a pointer and use arrow syntax to access its fields and methods.

Example

Before
ArrayList<Particle> particles; Particle p = particles.get(0); p.update();
After
ArrayList<Particle> particles; Particle* p = particles.get(0); p->update();

Notes

This mirrors how Java actually works under the hood. When you write Particle p = list.get(0) in Java, p is a reference to the original object, not a copy of it. CppMode maps that directly to a C++ pointer so the same mutation and lifetime behaviour applies. Adding objects works with either particles.add(Particle(x, y)) or particles.add(new Particle(x, y)) — CppMode handles heap allocation in both cases. Calling particles.remove(0) removes the pointer from the list but does not delete the object. Related: E0004.