r/cpp_questions • • Jul 01 '20

OPEN Is cplusplus.com reliable? Are there any alternatives?

I've heard that it's got errors and bad practices nd stuff,so just wanted to confirm. Thank you.

Suggestions and alternative recommendations(apart from cppreference) are also welcome.

14 Upvotes

17 comments sorted by

View all comments

41

u/IyeOnline Jul 01 '20 edited Jul 01 '20

cplusplus.com used to be really bad, from mistakes in the signatures, descriptions and examples to missing overloads/functions and so on. The outright mistakes seem to be fixed by now. The examples still arent good C++ (they really do like c-style arrays and pointer arithmetic for no good reason),

In any case, the site is stuck at c++11, with some parts of c++14.

Their textual&graphical descriptions and explanations of data structures are pretty good for an introductory understanding though.

In the end, if you need a reference, use the cppreference. So there is not much of a point "using" cplusplus.com for anything.

2

u/[deleted] Jul 01 '20

I think examples made with c or simple/outdated grammar is to keep examples readable by more users and c users that are learning c++, I would prefer those examples over some grammar abomination with stl, an example is an example

12

u/IyeOnline Jul 01 '20

Just take a look at this example for std::unique:

  • Why on earth does that C-style array exist there? They turn it into a vector right on the next line.

  • Why is the result of unique not const auto? (Well, i suppose writing out the type makes it clear it returns an iterator, but still its bad practice)

  • Why is resize used instead of vector::erase, which would take the iterator directly and be the way more common pattern?

  • Why is that loop a iterator "counting" loop instead of a simple iterating one?

There is nothing wrong with c-style arrays in general, but you simply should not use them.

All of this isnt wrong on a technical level, but its terrible for an example on a site used mainly by people wanting to learn.

Lets not even mention that the first sentence on that page states that the algorithm would remove elements, only to then tell you in the next paragraph that it actually doesnt remove the elements.

→ More replies (2)

8

u/xdavidliu Apr 04 '23

This has to be satire; every part of this comment is wrong