Home > Back-end >  Class C
Class C

Time:11-10

C + + object-oriented features: encapsulation, inheritance and polymorphism
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:

refer to the second floor the frog studio reply:
the last sentence, calculateZC () is undefined, should be c1. CalculateZC ()

Yeah, knock on a cell phone, wrong, correct me thank bosses

CodePudding user response:

reference 1st floor ooolinux response:
examples, the radius of the best private,

Uh huh, okay, is in learning