www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/26/14:35:36

Newsgroups: comp.os.msdos.djgpp
From: "A. Jans-Beken" <jabe AT oce DOT nl>
Subject: Re: What is object orientated programming
Message-ID: <347C1B14.E8@oce.nl>
Sender: news AT oce DOT nl (The Daily News @ nntp01.oce.nl)
Organization: Océ-Nederland B.V.
References: <880060136 DOT 22763 DOT 0 DOT nnrp-03 DOT c2de5740 AT news DOT demon DOT co DOT uk> <01bcf8ed$6c893440$0200a8c0 AT ingo>
Mime-Version: 1.0
Date: Wed, 26 Nov 1997 12:50:28 GMT
Lines: 55
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ingo Ruhnke wrote:
> 
> Mike Coulson <Mike AT mcoolie DOT demon DOT co DOT uk> wrote
> >     What is object orientated programming and in what way does it differ
> > from normal C.
> >
> >     Thanks for any replies,
> >
> >     Mike.
> 
> Take a look at
>   http://www.icce.rug.nl/docs/cpp.html
> and
>   http://info.desy.de/gna/html/cc/
> maybe this should be enough for beginning
> 
> Ingo

Object Oriented Programming mainly means that programmers like to work
with objects that are known and understood by there customers.
Instead of:
  char *name, *address, *city; int age;
it is easier to just say:
  PERSON p;

In a lot of cases objects are named by the information they contain.
Example: PERSON contains data about an individual.

PERSON is then a struct with something extra (read on).
In C you could define this kind of behaviour also:
  typedef PERSON struct { char *name, *address ... };

In C++ also operations (methods) are defined as part of an object.
  class PERSON {
    char *name, *address, *city;
    int age;
    
    // Methods
    void define_person(PERSON& p) {
       p.name = "Mike";
       p.address = "Hell Street";
       ...
       }
    }; // end of class

The nice thing of these operations is that they actually form the
interface to the object. For a programmer it is no longer necessary to
know all data-members from the class. If the functions
user_input_person(), print_person(); compare_person(); are available (as
methods of the class) it is possible to work with a sorted list of
persons.

The C++ compiler not only checks if your code is good, it also checks if
the methods are valid for the object you want to use them on. This
prevents bad or unclear programming.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019