Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Extending C for Object-Oriented Programming


July 1993/Extending C for Object-Oriented Programming/Sidebar

What is an Object? A Quick Review


  • Object-oriented design means modelling a problem domain with related objects.
  • Objects have state and are eligible to participate in behaviors which can change that state.
  • Object-oriented programming means implementing an object-oriented design with data structures and functions.
  • Data structures represent the state of an object.
  • Functions associated with an object define the methods for accessing and changing the state of an object, that is, for making the object behave.
  • Simple objects are common in C libraries. For example, the Standard I/O library provides simple file objects consisting of a FILE data structure and a set of associated functions that operate on a pointer to a FILE structure.
  • Inheritance is the relation of derivation among different types, or classes, of objects. If class Z is derived from class Y, and class Y is derived from class X, then X and Y are called base classes of Z.
  • Derivation of a class from a base class means extending the base class by adding new object data, adding new object methods, and redefining existing object methods.
  • Polymorphism, "having many forms," means that an object of a derived class can be referenced wherever an object of a base class is called for, but will behave as appropriate to its type. That is, if an object method has been redefined, then the redefining function, not the original function, will be called.
  • Dynamic binding is a means of achieving polymorphism. With dynamic binding, when a method is invoked the function to call is determined at runtime. Dynamic binding is supported in C++ by virtual functions. C provides no equivalent facility, but switch statements or pointers to functions can be used to imitate it. Static binding is monomorphic. When a method is invoked, the function to call is determined at compile time. Static binding is supported by ordinary C function calls.

Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.