by angelortega on 10/15/11, 7:46 AM with 38 comments
by exDM69 on 10/15/11, 9:02 AM
The biggest problem I saw was that it introduces classes and objects but does not tell you anything about the "rule of 3", destructors, copy constructors and assignment operators. These are crucial to understanding C++'s pass-by-value semantics and writing sensible C++. C++11 adds to this mess by adding rvalue references, move constructors and whatnot. Writing good and safe C++ requires you to use stack based resource management wisely and use ctors/dtors for initialization and cleanup (this is also why you almost never write try/catch in C++ - and there's no finally statement).
Another example: the article shows you how to do a Java-like constructor like this: point::point(int x, int y) { this->x = x; this->y = y; }
When in C++ you want to use initializer lists like this: point::point(int x, int y) : x(x), y(y) {}
At best this tutorial teaches you to write "C/C++" (the worlds most popular programming language that does not exist) or "C with classes". This style of programming has all the disadvantages of writing C but none of the advantages of C++.
C++ is one of the most complicated languages out there, on par with Haskell and Scala. It's C legacy makes it also somewhat dangerous and the pass-by-value semantics make it very different from any other language out there. You cannot expect to learn even a little bit of C++ from little vague blog posts like this.
If you want to learn C++, buy a book! The web is full of crappy resources like this one.
by obiterdictum on 10/15/11, 9:20 AM
In fact, if you are learning C++, you better start it as a new language, rather than a tumor grown on the side of C. These languages are too idiomatically different.
by AshleysBrain on 10/15/11, 4:08 PM
const methods - if you declare a const rectangle r, you can't call r.surface() unless it's declared int surface(void) const {....
references - article seems to be confused why they exist. They enable some extra handy features, e.g. you can pass a temporary to a function parameter taking a const reference. e.g. you can pass f(MyClass()) if it's declared void f(const MyClass&), but not if it's declared void f(const MyClass*).
STL - things like std::string, std::vector, std::map - totally invaluable!
And lastly, the fact that programming in C++ is completely different to C. It's not like C with bolted on features. It's a whole new paradigm. For example, in modern C++, you very rarely have to manage memory. Smart pointers and containers can generally manage it all for you.
by js2 on 10/15/11, 12:30 PM
Also grab a copy of effective c++ by scott meyers.
by 5hoom on 10/15/11, 8:14 AM
That would normally be about a chapter per-paragraph in most C++ resources around. Well done :)
by DCoder on 10/15/11, 1:49 PM
template <class ttype>
ttype multiply(ttype a, ttype b)
{
return a * b;
}
int * int doesn't always fit in an int. C++ Templates: The Definitive Guide suggests using a traits class to solve problems like this. Templates are a complex subject in general, and I wouldn't recommend using them without having read the aforementioned book.by Hitchhiker on 10/15/11, 11:08 AM
http://lwn.net/Articles/249460/
p.s. best comment in defense of the original poster so far has been by Shin Lao.
p.p.s the tut was targeted for a very specific audience + purpose. It was not purporting to be Bjarne Stroustrup's next meditation. Folks can offer support to another community member _ without _ being mean.
by Hitchhiker on 10/15/11, 8:10 AM
by tripzilch on 10/15/11, 8:54 AM
Kudos!
by etanol on 10/15/11, 11:24 AM
Someone doesn't understand the value of the "struct" keyword:
https://github.com/torvalds/linux/blob/master/Documentation/...
by Hitchhiker on 10/15/11, 8:29 AM
http://news.ycombinator.com/item?id=3114374
I second 5hoom's additional attribute that you have demonstrated.
by dbattaglia on 10/15/11, 1:18 PM
by KonradKlause on 10/15/11, 9:57 AM
by LostInTheWoods2 on 10/15/11, 4:30 PM
by forgotAgain on 10/15/11, 4:56 PM
by X4 on 10/15/11, 9:25 PM