↑ arvau

Wikipedia / C with Classes

C with Classes was the historical precursor language to what would later become C++, both of which were first created by Danish computer scientist Bjarne Stroustrup. As its name suggests, it aimed to extend the C language with object-oriented features, namely classes.

The term "C with classes" has also been used colloquially (sometimes disparagingly) to refer to C++ code written as if it were C.

History

In 1979, Bjarne Stroustrup began work on C with Classes. The motivation for creating a new language originated from Stroustrup's experience in programming for his PhD thesis. Stroustrup found that Simula had features that were very helpful for large software development, but the language was too slow for practical use, while BCPL was fast but too low-level to be suitable for large software development. When Stroustrup started working in AT&T Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed computing. Remembering his PhD experience, Stroustrup set out to enhance the C language with Simula-like features. C was chosen because it was general-purpose, fast, portable, and widely used. In addition to C and Simula's influences, other languages influenced this new language, including ALGOL 68, Ada, CLU, and ML.

Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre, including classes, derived classes, strong typing, inlining, and default arguments.

In 1982, Stroustrup began designing a cleaned-up and extended successor to C with Classes, using traditional compiler technology. The language was briefly called C84 before the name C++ was adopted; the name was suggested by Rick Mascitti and refers to C's increment operator. The resulting language included virtual functions, function and operator overloading, references, , improved type checking, user-controlled free-store memory allocation (/), and BCPL-style single-line comments. Stroustrup also designed and implemented Cfront, the C++ compiler front end, between spring 1982 and summer 1983.

Language

The language's constructors and destructors, rather than using the class names (X() and ~X()), used the new and delete keywords themselves as methods returning ; these keywords served to replace the C memory allocation functions malloc() and free(). C with Classes lacked the keyword, and had only a keyword to declare a public region of the class, while everything before was private.

C with Classes, which lacked namespaces, did not use the namespace resolution operator :: for referring to class members; rather, it used the period ., much like C. Providing the definition of a class method inside the class itself inlined the function, avoiding the function call overhead. In early iterations of C with Classes, every class would also have and (implicitly defined if not explicitly written) methods which would be called before and after (respectively) every function call.

C with Classes did not have virtual functions or function and operator overloading; these were not added until C++ in 1984.

Templates did not appear until Cfront 3.0 in 1991, and namespaces not until 1993; exceptions were first conceived for C++ around 1990 but only implemented in 1992.

Library additions

Stroustrup wrote various library headers for C with Classes; the most notable of these were a task library (<task.h>) for Simula-style concurrency, as well as a stream-based I/O library (<stream.h>, which would later become the foundation for the <iostream> header.

See also

References