So, it’s been 5 or 6 years since I’ve used C++ for a large project, and about half a year since I last had to deal with small/trivial C++ programs and the C++ runtime in general. I’ve decided I want to re-learn the language, primarily because it might prove very relevant for an upcoming project at work.
I’ve been working mainly with C and Python, and I’m currently at a point where I’m not even at ease with the for loop syntax below:
for( int i(0); i != n; ++i) {}
although I admit it’s not that hard to decipher.
Since I understand there’s been a lot of additions to the language as well as libraries and of course idioms, patterns and styles, I’d like to ask for your opinions on good resources that are up to date. I’d like to avoid the tutorials that take the approach “This is C with a lot of extras”. I still have my obligatory copy of “The C++ Programming Language” which I’m studying but I honestly don’t know exactly where to focus next. Design patterns? Templates and STL/Boost? Something else?
I’m open to all suggestions!
Also, a more specific question regarding typedefs. Is the following:
typedef Type& TypeRef;
generally considered good practice when providing opaque types as part of an API? With a meaningful name, that is. Is it at all similar to the approach adopted by libraries like pthreads or libpcap, and if it is, is it preferable to using a pointer for the same job?
Thanks in advance.
To answer your specific question, typedefs that hide the fact that something is a pointer or a reference are always a bad idea – the same is true in C. Consider for example the opaque type FILE – one still has to explicitly create FILE pointers in order to use it.
As for books, see The Definitive C++ Book Guide and List.