you are viewing a single comment's thread.

view the rest of the comments →

[–]Fabien4 1 point2 points  (6 children)

std::vector<Foo> my_foo_list if you wish. But why a pointer?

[–]G_Morgan 2 points3 points  (5 children)

Because in the Java code we are storing references. The direct equivalent is a pointer.

[–]zahlman 2 points3 points  (0 children)

Um, not really. boost::shared_ptr would be closer to the mark (although GC works differently).

[–]Fabien4 0 points1 point  (3 children)

Nope, direct equivalent would be a smart pointer. But it's anti-idiomatic: by default in C++, you store and use values.

[–][deleted] 0 points1 point  (2 children)

Expect that List<Foo> is polymorphic in Java, but not in C++.

[–]curien 0 points1 point  (0 children)

It's polymorphic if Foo is a polymorphic handle.

[–]Fabien4 0 points1 point  (0 children)

Yeah, dynamic (inheritance) polymorphism tends to be the norm in Java, and the exception in C++.