class
In C++, class can be seen as an upgrade version of struct in C. In a class, there can be variables, constants and functions which can be divided into three sections: private, protected and public. Parent classes can derive son classes and son classes can inherit certain characters from their parents.
The variables defined by a class is called an object. C++ sometimes referred to as the "Object Oriented Programming " language (OOP). Here is a flow chart below shows the difference between C & C++ and how is C++ orienting to Objects.
And here is an example shows how to work with classes in C++ below.
Example:
Notice: in the code, the class pointer was deleted. Remembering deleting the useless objects in your codes is a good habit for programming.
Results:
As you can see in the class <angl>, I defined two construction functions. The default construction function is the empty function: angl(){} which is used to initialize the object we defined afterwards in the main function. To find out more about initializing, please find the following website: http://c.biancheng.net/cpp/biancheng/view/2979.html
Moreover, if we use the keyword "typedef" on the class <angl>, it will help us to use the class more conveniently.
The "wrapping" by classes makes the construction of projects much easier. However, the OOP style does not improve the efficiency of the codes. This programming maner was created just to make it easier for programmer to order their codes.
In a real coding case, people usually decare functions in the header and specify the function in the source file.
Useful Links:
http://c.biancheng.net/cpp/biancheng/view/2968.html
http://www.cnblogs.com/mr-wid/archive/2013/02/18/2916309.html