Think things are available as a c + + object
The object itself have attributes and behavior
With the same nature of the object, called class
One of encapsulation meaning:
C + + attributes and behaviors to write together, performance things
Grammar: public class name {properties/permissions};
Example: designing a class, for the circumference of the circle
The class Circle
{
Public://access to public authority
Int m_r;//attribute radius
Double calculateZC ()//behavior to get round the circumference of the
{
Return 2 * PI * m_r;
}
}
Int main ()
{
Circle c1;//by class, create a specific round
C1. M_r=10;//to round object attribute assignment
Cout<& lt;" The circumference of the circle is "& lt;
}
CodePudding user response:
Examples, the radius of the best private,CodePudding user response:
The last sentence, calculateZC () is undefined, should be c1. CalculateZC ()CodePudding user response: