C with Classes(ID:886/cwi002)

OO Extensions to C 

Short-lived predecessor to C++.

Related languages
C => C with Classes   Evolution of
SIMULA 67 => C with Classes   Influence
C with Classes => C++   Evolution of

  • Stroustrup, B. "Classes: An Abstract Data Type Facility for the C Language", CSTR-84 Bell Labs, Apr 1980 view details
  • Stroustrup, B. "Classes: An Abstract Data Type Facility for the C Language" view details Abstract: Language constructs for definition and use of abstract data types ease the design and maintenance of large programs. This paper describes the C class concept, an extension to the C language providing such constructs. A class is defined using standard C data types and functions, and it can itself be used as a building block for new classes. A class provides a way of restricting access to a data structure to a specific set of functions associated with it, without incurring significant overheads at compile time or at run time.The C class concept is introduced by small examples of its use, and familiarity with the C language [2] is assumed. Appendix A is a complete small C program using classes.Classes have been in use for more than a year on a dozen PDP11 and VAX UNIX systems [1], and they are currently used for a diverse set of projects on more than 30 systems. Classes are currently implemented by an intermediate pass of the cc compiler, called the class pre-processor, which is invoked when the directive #class is found in a C source file. The class pre-processor is easily ported to a system with a version of the portable C compiler. A Motorola68000 version is in use DOI Extract: Postscript
    The aim of the class design was to provide the C programmer with a set of tools allowing the structure of a "medium sized C program*" to be expressed more clearly and directly than had been possible before. The practical integration of the class concept with the facilities of the C programming environment was considered far more important than any abstract notion of programming language perfection.
    The programmer is not asked to sacrifice "efficiency" to an abstract notion of beauty enforced through restrictions on the use of the language or through the provision of facilities which imply significant compile time or run time overheads. The aim has been to enhance C as a practical systems programming language, not to provide a new programming environment with a higher level of semantics. With the exception of the introduction of the new keywords class, public, etc. all older C programs preserve their meaning.
    The permissive nature of C has been preserved. For example, it is possible to have public data members of a class and to use casts on class pointers, thus ignoring the ideal that all operations on an object of an abstract data type ought to be restricted to a few well defined operations. This ideal is, however, not shared by everybody, and therefore not enforced through the language design. If it is yours you can adhere to it, and because the class pre-processor records dependencies between classes you can easily verify if a program passes this criterion of cleanliness. A version of the class pre-processor, called class, will write out the recorded dependencies. Because a more general set of dependencies is recorded the output of class can be used for a variety of purposes. Another use would be to determine whether any function of a given class accessed global data, or whether any function of a class took advantage of the ability to access not only the object for which it was called, but also other objects of the same class.
    Extract: Introduction
    It is common practice to provide non-trivial data structures with a set of access functions. This practice helps preserve the consistency of the data and also aids programmers in the task of writing and modifying programs. Classes have been added to the C language to allow functions to be explicitly associated with data, and to protect the data against "irregular" access from other functions.
          in SIGPLAN Notices 17(01) January 1982 view details