Introduction to Computer Science & Information Systems
C++
- C++
- An extension to the C
language developed primarily by B.Stroustrup at AT&T Bell Laboratories:
it supports object-oriented programming among
other enhancements.
- C
- A language developed in conjunction with the
UNIX operating system at AT&T Bell Laboratories
by D.Ritchie and now an ANSI standard. It has grown
popular due to its simplicity, efficiency, and flexibility.
C programs are often easily adapted to new environments.
- Object-oriented
- Applied to analysis,
design and programming. The basic concept in this approach is that of objects,
which consist of data structures encapsulated with a set of routines,
often called "methods" which operate on the data. Operations on the data must be
performed via these methods, which are common to all instances of objects of a
particular class. Thus, the interface to objects is well defined, and allows the
code implementing the methods to be changed so long as the interface remains the
same.
- UNIX
- Computer operating system developed by Bell Labs.
Since it was written in C, it was possible to port it to run on
different hardware architectures. It is now offered by many manufacturers and is
the subject of an international standardisation effort.
Object-oriented Programming
Object-Oriented Programming (OOP) is a relatively new method for software
systems design and implementation. It is different from Procedural Programming
from the design angle. There are several major concepts in OOP, they are:
- Abstract Data Type (ADT)
- Class
- Object
- Inheritance
- Polymorphism, etc.
What is the Motivation of Object-Oriented Programming?
Object-Oriented Programming is a paradigm or organising principle for software,
where the program is structured according to the information it manipulates,
rather than the operations it does. Data, not procedures, shape the program.
Some programming languages such as Smalltalk and C++ explicitly support
object-oriented programming. They provide the tools for programmers to fulfil
two principles:
- Localize information
The localization of information is supported by encapsulation - the ability to
bundle data and functions into self-contained objects.
- Exploit existing solutions
Exploitation of existing solutions is supported by the language being extensible
in several powerful ways, meaning that reuse and modification is easy.
Procedural programming
Procedural program is written as a list of instructions, telling the computer,
step-by-step, what to do: Open a file, read a number, multiply by 4,
display something. Most traditional computer languages like Basic Pascal, C and
FORTRAN are procedural.
Procedural programming is fine for small projects. It is the most natural way to
tell a computer what to do, and the computer processor's own language,
machine code, is procedural, so the translation of the procedural high-level
language into machine code is straightforward and efficient. What is more,
procedural programming has a built-in way of splitting big lists of instructions
into smaller lists: the function.
Elementary Programming in C++
The elementary programming in C++ is almost the same as C. Only a few differeces between them. So, after you know these differences, you can learn the new concepts in Object-Oriented Programming in C++.
What is diferent between C and C++?
Here is a simple C++ program:
#include <iostream.h> //Everything in C++ that involves basic user input
//output is defined in this header file
int main()
{
cout << "Hello\n";
return 0;
}
C++ is based on the older language C. For this example only, we are going to consider the equivalent program written in C. The C example is shorter and simpler:
main()
{
printf("Hello\n");
}
Creating, Compiling, and Linking a C++ program using Borland4.5 C++
// Creating the Source Code
Borland4.5 C++ Screen layout: Create a new project myfirst.ide
// Compilation and Linking
Borland4.5 C++ Screen layout: Compile and link the myfirst.cpp program