Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Advanced C++ : Get involved in OOP and Classes


Advanced C++ : Get involved in OOP and Classes

By mido avatarmido | 5884 Reads |
0     0

C++ Introduction (Differences between C and C++, and OOP definition)

Programming languages like Pascal, C, BASIC, Fortran are Procedural programming languages, since every command of the language tells the computer to do something, like : gets inputs, total of addition operation, etc… Then the program here is just a series of instructions. When writing a very HUGE program, its complicated then, no programmer can deal with the program, or writing easily, unless you've divided it into partial units. So depend in C on whats called 'Functions' In order to facilitate the building a complicated program operation. in other programming languages, depended on 'Subprograms', or 'Subroutines' or 'Procedures', i.e the program would be divided into several functions each refocusing by the specific process. The idea of "Dividing the program" expanded to functions, so several functions can form an independent software unit called "Module". Sumarry…Dividing the program to functions and modules considered one of the basic idea in structural programming

C++ is just a development for standard C Programming Language…, therfore most of C concepts , commands, and exepressions have been kept, and this language (C), is available in C++, but C++ of course is not supported by C… Most Important ideas that Distinguish C++ From C, are : Classes, Objects, and OOP (Objective Oriented Programming), In addition to a new style in I/O (input/output), and in Comments… The basic idea from OOP languages is Data collecting, and Functions, which applied on the data in an independent softwar unit. This unit called "Object".

Classes:

In OOP we always say that Objects are members of classes. As we know that every programing language has special datatype, like the type "int" in C++, which allows variables definitions to you . in a similar way, we can define many objects from a class. Class is used to determine which any data or functions used in this Class' Object, defining a class wont form any object, like "int" won't form a variable and therefore, we say that a class is group of Identical objects, like singers "Madonna", "Sting", "Prince", are members in Rock music Class, we don't know someone called "Rock Music", but there are specific persons with specific names are members in this class, if they have certain qualities

Inheritance:

The idea of Classes lead us to inheritance. In our daily life, we use the concept of classes divided into several partial classes, for example, Animals Class divided into these following partial classes: Flies, Birds, Mammels, etc… Either, vehicles are divided into : Cars, Busses, Motorcycles, etc…

The concept here, is the partial class involves the same specifications with the class which was derived from. Cars, Busses, and Motorcycles, all have wheels and engines, which is the main defination for vehicles. between the members of one class, there can be for each partial class, its special specifications. e.g Bus has chairs for many people, whereas car has a certain space for loading large quantities…with the same simulation, it can be applied on OOP languages. Inheritance sometimes resembling using functions to simplify the procedural program, if we have found that three sections of the procedural programm often do the same task, we find that the opportunity is clear to reducing the common elements for the three sections and putting them in one function. The three selections can call that function to process the required task…

Thats it (for now) Thanks for reading…

Comments
spyware's avatar
spyware 17 years ago

The article looks very messy. (don't kill me but) I think you re-wrote an existing article.

ghost's avatar
ghost 17 years ago

zero explanation for the actual code

ghost's avatar
ghost 16 years ago

mido please help me my email is hacked by system_meltdown WAR_AT_HOME@HOTMAILCOM