Hi Arcadiu!
Well, OOP has some advantages over procedural programing.The base of OOP programming are, as far as i know, classes. A class is basically a data type that you make yourself, like int or boll or char, but this time you make the data type.Of course you make that data type out of the existing data types in that programming language, in the case of C++ you make your data type out of int, bool, char, string, etc.For example:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
class Student
{
string name;
int average_grade;
bool passed_exams;
//etc.
}
Student Alex_Smith; /* just like you would create a normal variable, except Alex_Smith is a variable of type Student */
Alex_Smith.name="Alex Smith"; // change the value of the name
Alex_Smith.average_grade=9.4; // change the value of the average grade
Alex_Smith.passed_exams= TRUE; // the student passed the exams
|
As you can see the data is grouped into one whole, it's not separated, name, average_grade and passed_exams are all grouped together.
The difference between C++ and C is that you can also put functions, not just variables inside classes.Of course, in C they are called structures.C++ has both, but there is only one difference between them.So you can do:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
class Student
{
string name;
int average_grade;
bool passed_exams;
//etc.
change_grades(); //function that chaenges grades, just an example, it does not have parameters
graduate(); function that "graduates" the student
}
Student Alex_Smith; /* just like you would create a normal variable, except Alex_Smith is a variable of type Student */
Alex_Smith.name="Alex Smith"; // change the value of the name
Alex_Smith.average_grade=9.4; // change the value of the average grade
Alex_Smith.passed_exams= TRUE; // the student passed the exams
Alex_Smith.graduate(); // now we've made the student graduate
|
Anyway please read the tutorias from this site or from other sites if you do not have a book.
All i'm trying to say is that C++ offers both procedural programming and OOP programming.You chose how to combine them or you can even use just one.C only offers very limited, if not, any OPP an Java enforces only OPP programming.In C++ you have more freedom.