cplus_3.0_manual - C 3.0 Programmers Manual Document...

This preview shows page 1 - 4 out of 22 pages.

“C+” 3.0 Programmer’s Manual Document Revision C May 2007 Miro Samek, Ph.D. q uantum L e a p s™ , LLC Copyright © 2002-2007 q uantum L e a p s , LLC Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with this copyright notice being preserved. A copy of the license is available from the Free Software Foundation at: .
Image of page 1
“C+” Programmer’s Manual www. q uantum- L e a p s .com Table of Contents 1 Introduction ........................................................................................................... 1 1.1 Licensing ......................................................................................................... 1 2 Getting Started with “C+” ........................................................................................ 2 2.1 Installation ...................................................................................................... 2 2.2 Borland Turbo C++ 1.01 .................................................................................... 3 2.3 GNU Make ........................................................................................................ 3 2.4 Compiling the “C+” Library ................................................................................. 3 2.5 Building the Test Application ............................................................................... 4 2.6 Running the Test .............................................................................................. 4 3 “C+” Overview ....................................................................................................... 5 3.1 Encapsulation ................................................................................................... 5 3.2 Inheritance ...................................................................................................... 6 3.3 Polymorphism .................................................................................................. 8 3.4 Costs and Overhead ........................................................................................ 13 4 An Annotated Example .......................................................................................... 14 4.1 Subclassing Shape .......................................................................................... 17 4.2 Executing the Test .......................................................................................... 18 5 Summary ............................................................................................................ 19 6 References ........................................................................................................... 20 7 Contact Information .............................................................................................. 20 Copyright © 2002-2007 q uantum L e a p s , LLC
Image of page 2
“C+” Programmer’s Manual www. q uantum- L e a p s .com C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. Bjarne Stroustrup 1 Introduction Object-oriented programming (OOP) is not the use of a particular language or a tool. It is rather a way of design based on the three fundamental design meta-patterns: Encapsulation —the ability to package data and functions into classes Inheritance —the ability to define new classes based on existing classes in order to obtain code reuse and code organization Polymorphism —the ability to substitute objects of matching interfaces for one another at runtime Although these meta-patterns are traditionally associated with object-oriented languages, such as Smalltalk, C++, or Java, you can implement them in almost any programming language in- cluding C 1 and even assembly 2 . Indeed, as Frederick Brooks [Brooks 95] observes: … any of these disciplines [object-oriented meta-patterns] can be had without taking the whole Smalltalk or C++ package—many of them predated object-oriented technology. In fact, virtually any larger software system, regardless of implementation language, uses the meta-patterns of “Abstraction”, “Inheritance”, or “Polymorphism” in some form or another. Easy to identify examples include OSF/Motif (the popular, object-oriented graphical user inter- face), and Java Native Interface, both of which are implemented in C. You don’t need to look far to find many more such examples. OOP in an object-oriented language is straightforward, because such a language natively sup- ports the three fundamental meta-patterns. However, you can also implement these patterns in other languages, such as C, as sets of conventions and idioms. I call my set of such conven- tions and idioms “ C+” [Samek 02]. The main objective of “C+” is to achieve performance and maintainability equivalent to the C++ object model. In fact, “C+” is, to a large degree, an ex-
Image of page 3

Want to read all 22 pages?

Image of page 4

Want to read all 22 pages?

You've reached the end of your free preview.

Want to read all 22 pages?

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern