Solo disponible en BuenasTareas
  • Páginas : 9 (2105 palabras )
  • Descarga(s) : 0
  • Publicado : 27 de agosto de 2012
Leer documento completo
Vista previa del texto
A Brief Look at C++
Bjarne Stroustrup AT&T Bell Laboratories Murray Hill, New Jersey 07974

ABSTRACT This note describes some key aspects of what C++ is and of how C++ has developed over the years. The perspective is that of an experienced C++ user looking at C++ as a practical tool. No attempts are made to compare C++ to other languages, though I have tried to answer some questions that Ihave often heard asked by Lisp programmers.

1 Introduction Like all living languages, C++ has grown and changed over the years. For me, the improvements to C++ have seemed almost glacially slow and inevitable; they are natural developments of C++’s own internal logic and deliberate responses to the experiences of hundred of thousands of users. To many who wanted to use C++ aggressively, thisgrowth has been frustratingly slow and timid. To some who considered C++ only infrequently, the developments have seem like unpredictable lurches into the unknown. To others, C++ has simply been something peripheral about which little concrete was known, but about which a multitude of strange rumors persisted. However you look at it, C++ has developed significantly since its first appearance. As anexample, consider a simple function that sorts a container and then counts the number of entries between Dahl and Nygaard:
template int cnt(C& v) { sort(c.begin(),v.end()); C::iterator d = find(v.begin(), v.end(), "Dahl"); return count(d, find(d, v.end(), "Nygaard")); }

A container is seen as a sequence of elements from begin() to end(). An iterator identifies an element in a container. Thistemplate function will work as described for any container that conforms to the conventions of the C++ standard library with elements that can be compared to string literals. For example:
vector v; list lst; // ... int i1 = cnt(v); int i2 = cnt(lst); // vector of C-style strings // list of C++ strings

The types vector, list, and string are parts of the standard C++ library. Naturally, we need notbuild the string values Dahl and Nyggard into our little function. In fact, it is easy to generalize the function to do perform an arbitrary action on a range of values of arbitrary types in a container of arbitrary type. Clearly, this style of programming is far from traditional C programming. However, C++ has not lost touch with C’s primary virtues: flexibility and efficiency. For example, theC++ standard library algorithm sort() used here is for many simple and realistic examples several times faster than the C standard library qsort() function.


2 The C++ Standard C++ is a statically-typed general-purpose language relying on classes and virtual functions to support object-oriented programming, templates to support generic programming, and providing low-level facilities tosupport detailed systems programming. That fundamental concept is sound. I don’t think this can be proven in any strict sense, but I have seen enough great C++ code and enough successful large-scale projects using C++ for it to satisfy me of its validity. By 1989, the number of C++ users and the number of independent C++ implementors and tools providers made standardization inevitable. Thealternative was to allow C++ to fracture into dialects. In 1995, the ANSI and ISO C++ standards committees reached a level of stability of the language and standard library features and a degree of precision of the description that allowed a draft standard to be issued [Koenig,1995]. A formal standard is likely in late 1996 or early 1997. During standardization, significant features and libraries wereadded to C++. In general, the standards process confirmed and strengthened the fundamental nature of C++ and made it more coherent. A description of the new features and some of the reasoning that led to their adoption can be found in [Stroustrup,1994]. So can discussions of older features and of features that were considered but didn’t make it into C++. 2.1 Language Features Basically Standard C++...
tracking img