@Anmol444
No, private means that direct access is only granted to member functions of the class. Access applies to variables as well as functions. A class has what is called an interface - public functions which allow interaction with the private member variables. By restricting access to only these functions, one can control what happens. However it is still up to the coder to do the right thing.
For the Arc example - which stores a centre point, radius, start angle, end angle, start point, end point: we want to provide a function that allows us to change the start point of the arc. It is still the responsibility of the coder to ensure that all the others variables are recalculated in this function. This is much better than allowing anything to alter a variable which invalidates the whole object.
About private functions, but first some quick geometry: It is possible to calculate an arc given 3 points on it. Join the 3 points with 2 line segments, the perpendicular bisectors to these line segments (they are normals) intersect at the centre point of the arc. There is quite a bit of calculating to do here, and functions like finding the angle & distance of the line segments shouldn't be part of the public interface, so these functions would be private.
An arc class is an interesting one, there are lots of ways to create a new arc - so there are lots of constructors. There are also lots of ways to modify an arc, so there are lots of functions to allow this. To achieve the overloading of the functions, one has to create classes for all the argument types, because the arguments have to differ by type & number. Further, there are various things like intersections with other arcs & lines, and tests like Point on Arc, Is arc tangential to another arc or line.
The const qualifier is a different thing to private access. It means that the value cannot be changed, and is used for function arguments and return types and for constant values like these:
1 2
|
const int SIZE = 10; //Array size
const double GRAVITY = 9.8;
|
I think you would benefit from reading the tutorial on this site - top left of this page.
Hope all goes well.