when was RAII added to C++ - c++

I recently learned about the wonderful memory management technique of RAII, which seems so much cleaner than the new/delete headache I learned in school years ago (I haven't looked at much C++ during the intervening years).
I'm trying to track down when this great technique was added to C++. Was it always there and I just missed the memo? What's the oldest version of the C++ standard which supports RAII?
[UPDATE: OK I realize now why this isn't an ideal SO question -- I have no practical way to verify whether any given answer is correct! Nonetheless I'm still very interested to learn the answer, and I assume the majority opinion will be true.
What I'm hearing is that it's always been there, which I don't doubt is true, but begs the question how come none of my old text books mention it? I just checked Meyers' Effective C++ 2nd edition which I have handy, and will check older texts tonight. Maybe the term was only recently coined, while the technique existed long before?]

When exactly the term "RAII" was coined, I'm not sure. But the technique itself existed in C++ from the moment of its invention, circa 1979.
The first version of the C++ ISO standard was published in 1998.

Any language that has scoped variables with automatic destructor calls is able to do RAII. C++ had this concept from the very beginning as calling destructor when execution leaves scope where variable is declared was in C++ from the very beginning.

Wikipedia's claim that Stroustrup invented RAII is backed by a reference to his book Design and Evolution of C++, published in 1994.
I don't have a copy to check, but it would seem to date from at least this time.

Related

Why some people say just "C+" instead of C++?

In the past I have seem a couple of people say C+ (with just one plus). I always thought that such persons were "ignorant" cos the language is called C++ not C+.
However, I was watching a youtube video were a guy said that there was a language called C+ before C++ (or C+ changed its name to C++, it is not clear what the guy is saying in the video). Is this correct? I never heard of just C+ before, is there any language called C+? If there is such language, is such language related to C++?
C+/ABCL is not related to C++ in any way, It is an different and unrelated language which is younger than C++.
I've never heard of it (and I've been around C++ for a long time now).
Bjarne Stroustrup doesn't mention it in The Design and Evolution of
C++_, and I guess he would know. The language was originally called
“C with Classes”, but the name was changed to
“C++” long before the language got out of AT&T. (There is
an ABCL/c+, but it has nothing to do with C++, and is much later.)

Resource that briefly describe the C and C++ standards

After having an answer here wrong, because I wasn't up to date on the C standard, I started to look for some place that gives a description of whats in the C and C++ standards.
I do not want the complete standards, of which I found links in Where do I find the current C or C++ standard documents?, or intimate technical discussions. Instead I would like something that briefly describes the standard, with references to the actual standard if I want to check it more thoroughly, and maybe saying which standard the feature was introduced in.
Is there such a resource available?
EDIT: A little background to the question: I have been programming C for over 20 years now, and when I learnt it not much was standardized. And what was in the official standard was not widely implemented. Through the years I have become good enough C programmer that my friends and colleges come to me for help when they have problems.
However, when I learned C I was told that things like memory layout for multi-dimensional arrays was implementation specific, and when I saw a question about that subject I said that it wasn't standardized only to be told I was wrong. But even knowing this, I have a hard time finding any place saying that it's in the standard, and it's even harder to find in which standard it was first introduced.
If there was some place saying "Memory layout of multi-dimensional arrays was standardized in C9x, in section Y of the standard document" It would have been easy to find and give this to the person asking the question. I am not intrested in what the actual layout is, just that it has been standardized, and where to look if I really want a definitive answer about it.
This of course goes for other things. Like knowing that header file "<yyy.h>" is mandated by standard "C90", and where in the standard I should look for the rationale and contents of it. It is very difficult to find these things when they are spread out, having it collected in one place would make it much easier to find.
Anything that's not the standard will either be not definitive, or be simplified in such a way as to be far less than useful. And anything definitive or really useful will basically be the standard.
I know of no resource that covers every section of the C standard (or even a sizable number of them) in a simplified way and I would doubt its usefulness. You generally have a specific issue you need solved and, in that case, you would search for that specific issue - the vast majority of people don't need the standard, especially when they have a resource like SO at their fingertips.
If you're a language implementer or enjoy examining the dark corners of the language in excruciating detail, then yes, get the standard, it's invaluable. If you're just using the language day-to-day (even as an expert), you can get by without it, with just a bit of googling (a).
(a) Make sure one of the search terms is site:stackoverflow.com :-)
I found http://en.cppreference.com/w/cpp is now becoming pretty good! (always much more complete)
There is so much material in the standard there is just no way to briefly describe it. I don't think your question is really answerable as written. If you want a reference for the standard library though, Josuttis' book http://www.amazon.com/Standard-Library-Tutorial-Reference/dp/0201379260/ref=sr_1_1?ie=UTF8&qid=1320994652&sr=8-1 is always a fantastic reference.
I'm guessing you already are familiar with the older standards and want to brush up on the newer less-used stuff.
Here is a good read for C99. It covers changes and has notes to the actual standard. Also some stuff on C++ in there.
Wikipedia is great for C++11. Great for basics, but doesn't go into full detail.
If you fully understand the language then you can generally infer the standard. For strange corner-cases you're going to have to refer to the standard.
I think some of the other people answering this question are right: one seldom needs the ultimately authoritative ISO standard document, unless you are writing a compiler or something like that. For me, I find that the main books on the two languages by the language creators are sufficient for almost all my needs. They are:
The C Programming Language by Brian Kernighan and Dennis Ritchie
The C++ Programming Language by Bjarne Stroustrup
Look for the latest editions of each, although a quick search on Amazon shows neither updated for the latest incarnations of the languages (C99 and C++11). You might need to supplement with online sources, or perhaps look at A C Primer Plus and Professional C++.

What do I need to know about C++0x? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Where can I learn more about C++0x?
I am fairly familiar with C++03 but I still need to come to terms with C++0x so I would like to read some fairly digestible information on C++0x.
I have looked at the Wikipedia but I am on the look out for something that is more readable. So is there a book or series of blog entries that provide a nice introduction to the matarial?
There is a ton of stuff on this very site - some of the posts include very informative discussion. I would point you to Google but it's going to be more efficient to search in C++0x tagged posts here imo.
Here's a good one to start with, which includes indirection to Stroustrup's own summary. Scott Meyers has presentation materials on the topic here.
Check up on your favourite compiler's support for the new version. Microsoft VC10 support is summarized here. GCC info can be found here.
Official state of the standard for the language is available here. Evolution of the language is in many places tied to ongoing work in Boost. See here for some info on that.
Honestly my preference these days is to look here for 99% of needed info rather than resort to a book.
It's too early for a book. The standard isn't fixed yet.
Now, if you think wikipedia is hard to read, you might try Stroustrup's page about it. However it might seem harder to read to some.
There's a good tutorial on codeproject here for VC++. Even if you aren't using Visual Studio though it's still useful.
Learn whatever feature you would have loved having in C++98 in the first place. For me, it was variadic templates, lambda functions, decltype and other cool stuff.
If you still don't know what to learn first, maybe you should try to understand what issues from the C++98 are adressed. I say this because all the xvalue, move semantics and al stuff is quite heavy to grasp if you don't know what the problems were (and still are btw). This may imply learning some more C++98 first.
Then, you can always browse the Wikipedia article and look at whatever you find cool. Implementors don't provide all the features yet, so you'll look like a 5 year old staring at the front window of a toy store. This is a good reason to behave like one.
I really liked this series of blog posts by the Visual C++ Team Blog:
The Future of the C++ Language
Lambdas, auto, and static_assert: C++0x Features in VC10, Part 1
Rvalue References: C++0x Features in VC10, Part 2
decltype: C++0x Features in VC10, Part 3
I found the Overview of the New C++ (C++0x) book by Scott Meyers to be a good, detailed summary of the main features. It's more of a presentation with very detailed footnotes that an actual book, but it's still an excellent, short read.
I suggest you using the book functionality of Wikipedia to make it more readable/printable. I did the same for the C++0x page.

When did C++ get nested classes?

Somehow I never noticed until today that C++ supports nested classes. This surprised me because when I was learning C++ back in the '90s, I specifically remember nested classes being something that Object Pascal and Java had, but which C++ did not. I asked an old programmer friend about it and he concurred that he recalls C++ not having nested classes.
Is my recollection of C++ not having nested classes mistaken, or were they actually added to the standard at some point in the past fifteen years? I tried searching Google for information on this topic and I haven't come up with anything helpful yet.
It could also be that I'm thinking of nested functions, which Pascal certainly supports but C does not.
According to "A History of C++: 1979−1991" by Bjarne Stroustrup
Later, after many technical problems
and much discontent from users, nested
class scopes were re−introduced into
C++ in 1989 [Ellis,1990].
see page 28 in http://www.research.att.com/~bs/hopl2.pdf
Nested classes were added in CFront 3.0, released in 1993.
EDIT It goes back even earlier, as you can see in the table of contents to The Annotated C++ Reference Manual (1990).
were they actually added to the
standard at some point in the past
fifteen years?
C++ was first standardised in 1998 and this standard included nested classes in section 9.7. Since your talking early 90s in your question it is quite possible that whatever particular compiler you were using at the time did not provide support for them.
So Nested Classe were officially supported from 1998 onwards but could have been available (depending on your compiler) at any time prior to this, as alluded to in the answer from Ken Bloom.

Where can I find a good quick reference for learning C after years of C++?

I last used C professionally around 1997 IIRC. I've used a lot of C++ since then. Now, I find I need to use some C again.
One thing I'm sure of is that I can't just drop the obvious C++ features (e.g. classes) and expect everything to work. There are various less obvious syntax changes. I just don't remember what they are.
Is there a good reference for making that transition again, but returning to C? If it explains the changes in C99 (and later?) that's even better.
As dirkgently suggests, Harbison and Steele is a good reference, but I don't find it useful to brush up on. To retrain your mind, I have these suggestions:
Reread Kernighan and Ritchie
Optional: read Peter van der Linden's superb Expert C Programming: Deep C Secrets.
Don't forget libraries! Look at P. J. Plauger's book The Standard C Library, or just go to http://dinkumware.com/ (Plauger's company) and browse their excellent documentation of the C99 libraries.
Standard C lacks data-structure libraries. Fortunately there is an excellent, free 3rd-party library that fills several voids: Dave Hanson's C Interfaces and Implementations.
Herbison and Steele: C: A Reference Manual, Fifth Edition may be of help w.r.t C99. Also, read up on the standard, the papers available at open-std.org. And finally, the compiler/tool-chain documentation you are plan to use. The latter puts everything in perspective -- as to how much you need to re-learn.
Not enough but a good starter : C for C++ Programmers
Not a book but read GTK+ source code. It may be fugly but it's got some of the best C source code I've ever read.
C for Programmers, by Leendert Ammeraal, is by far the best thing I have seen along these lines. Unfortunately, it is almost 20 years old, hard to find, and (obviously) not up to date on C99.
Try the following link, I have found it good for reference:
http://www.techbooksforfree.com/ccpp.shtml
Also Sarafi Books or Books24x7, (you have access to both using either ACM or IEEE membership), are excellent references for technical books.
Also, nothing can beat the K&R:
http://www.amazon.com/exec/obidos/ASIN/0131103628
http://www.amazon.com/exec/obidos/ASIN/013089592X
I think the above should give you enough reading material to last for a few weeks and you will emerge as an accomplished C programmer. All the Best. :-)