This might seem really, really cheeky (shout at me if you want) but if anyone has the time and wouldn't mind reading through my assignment, telling me if the information looks OK (it's only for a pass so not much detail is required) I'd be more than grateful. Thanks :)

Object Oriented Programming

Object-orientated programming is a programming language model that is organised around objects and data rather than logic. It is a paradigm language, which represents the different elements of a program (objects, functions, variables etc) unlike methodology that is used to solve specific programming problems.

There are different elements that make up OO programming. Some of which are:

• Classes
• Objects
• Inheritance
• Polymorphism
• Encapsulation
• Public and private instance variables
• Static references
• Modularity
• Reuse

This report describes each one from a programmer’s point of view.

A class is an implementation of an abstract data type. Classes describe the attributes (or data) of an object and also determine its behaviour.

For example, a class that holds data about a cat could have many characteristics such as breed, colour, name, age and the data can be customised to suit the particular cat depending on it’s characteristics without having to change coding.

Classes have three different types of members:

• Public: These are where the variables are set and are visible and can be accessed by all classes.
• Private: These are where the variables are set and can only be visible and accessed by the class they belong to.
• Protected: These are where the variables are set that can only be visible to the class they belong or to any subclasses.

An example of a class is:

class cat {
    int cat_age;
    char cat_colour;
    char cat_breed;
    char cat_name;
    void set_values (int age, char colour, char breed, char name);
    int getAge() {return (age;);}
    char getBreed() {return(breed;);}
    char getColour() {return(breed);}
    char getName() {return(name);}

void cat::set_values (int age, char colour, char breed, char name)
cat_age = age;
cat_colour = colour;
cat_breed = cat_breed;
cat_name = name;

int main () {
 cart c1, c2, c3, c4;
  c1.set_values (1, “green”, “labradore”, “Sally”);
  c2.set_values(2, “blue”, “Moggy”, “Jimmy”);
  return 0;

The following output would be:

Cat: Aged 1, Colour: green, Breed: Labrador and age: Sally

By using classes I can have many cats that each have different characteristics without having to set different variables each time which can become timely and sometimes can cause problems.


Objects lie at the canter of object-oriented programming. An object is something that can be viewed, used or plays a role within the program. A lorry for example is assembled from different aspects such as, engines, wheels and can have attributes like colour, speed or mileage, lorry being the object and engine and the wheels being the attributes.

A person can be an object, their hair, size and skin colour for example being their attributes. An example of this in C++:

Class Lorry() // the lorry is the object
		string make;
 		string engine;
		int engine_size;

Each lorry can have their own unique characteristics but always derive from the object.


Simula invented the concept of inheritance in 1987 as a way to form new classes and to make use of classes that have already been defined. The purpose of inheritance is to reuse existing code with little or no change to it at all.

Once the base class is defined and compiled there is no need to rework on it. The programmer can create as many derived classes from the base class adding as many features they like without having to change more coding than is necessary.

An example of inheritance used in C++ is when a class inherits data from it’s parent class:

class vehicle 
char colorname[20];
 int number_of_wheels;
  void start();
void stop();
void run();
class Car:
char type_of_fuel;

The derived class car has access to the protected members of the vehicle class. This means that it can inherit the data that is being passed by the vehicle.

Polymorphism means the ability to request the same operations to be carried out over and over again.

Polymorism enables the programmer to request the same objects to perform the same action.

An example of Polymorphism in C++ would be to have different animals and then perform a task on them at the same time, e.g. eat food. You could create one function called “Eat” and then each animal could do that function at the same time but contain different actions, for example the dog won’t eat cat food, the cat won’t eat dog food.

class cat

      // contains dog food

class dog

      // contains cat food

This example is showing that both classes have the method of “eat” but each can have different results with the methods being overloaded. The language must support polymophism to know which “eat” method applies to which object.

Encapsulation or information hiding is all about hiding the details of the implementation of the interface. Encapsulation is used to prevent users from needing to know the inner workings of the objects of the class.

A real life example of Encapsulation is we know that we can breath without knowing how our bodies perform it.

In C++ classes have two parts, the interface and the implementation. The interface is the implementation for the external interface (what the user sees) i.e. a human being. The implementation is code that performs all the operations, walking, eating, talking etc. The general user should not be able to see the inner workings of the interface.

Encapsulation is used for many reasons in C++ one of the main reasons is so that the implementation code can be changed without affecting the interface. Encapsulation also prevents the program the program from relying on other programs which one small change could have a massive effect.

Encapsulation can also help improve the performance, fix bugs and bring together coding.
Static References
A static variable is a mixture of global and local variables. Static variables has the same lifetime as a global variable whereas the scope of the variable could be like a local variable. It can be declared once and is only destroyed once the program is has finished.

Modularity is a programming technique used to separate the code into parts. It mainly refers to the include. An example of Modularity programming in C++ would be:

The simple function “cout” cannot be used unless the you include the file specifically designed to handle it. If however you wanted to include the function to handle “cout” it would take a lot up a lot of code and may cause errors in your program. That’s where modularity comes into play, enabling the programming to add include <iostream.h> allows the function to work and not having masses of coding in your project file.
Reuse is the most important aspect of OOP as it defines what the language is about. By reusing the code it makes programming more easy to understand and complete. It also is better for problem solving.

With 112 posts I know you know how to use code tags. Then edit your code to correct all the typing mistakes you made when posting those classes.