yes it is possible to make a private class in C++ but this class will not solve any purpose.................
Yes, you can declare a private class within another class. The internal class is effectively invisible to all classes and functions outwith the external class members.
Private construction prevents objects from the class from being instantiated other than via a static member function of the class, a friend function or a friend class.
The keyword is friend. The external function must be declared a friend of the class (from within the class itself) in order to become a member of the class and thus gain access to the private (and protected) members of the class.
In C++, the private specifier means that the item can only be accessed by methods of the class, not including methods of derived classes. Protected, on the other hand, means the item can be accessed by methods of the class, and methods of derived classes. Public, to complete the explanation, means that the item can be acessed by any method, this class, another class, or otherwise.
C++ does not have a built-in kilometre class. If you have such a class, it was provided for you by a third party. However, your IDE should be able to show you the members, including private members. I'd imagine such a class would have a private float or double member to store the actual number of kilometres it represents, and perhaps some public methods to convert the number to other formats, such as millimetres, centimetres, miles, yards, inches, etc.
Data encapsulation is enforced by restricting access to the class members. Access can be specified on a per-member basis, defaulting to private access for a class and public access for a struct. Private members are accessible to class members and to friends of the class. Protected members are the same as private members but are also accessible to derived class members. Public members are fully-accessible. Data members are typically declared private while interfaces are typically declared public or protected.
class class_name { private: data_members; public: member_functions; };
The private specifier states that the member can only be accessed by the containing class, and not by any derived class, nor by any other code outside of a class.
Public members in C++ have accessibility to any function that has scope to the instance of the class, whereas private members have accessibility only to functions of that class.
Private construction prevents objects from the class from being instantiated other than via a static member function of the class, a friend function or a friend class.
A private member can only be accessed by other methods of the same class, while a public member can be accessed by methods of any class or by non class code.
Yes.
The keyword is friend. The external function must be declared a friend of the class (from within the class itself) in order to become a member of the class and thus gain access to the private (and protected) members of the class.
Public member, fields, methods etc can be accessed from outside of the class. While private members etc can accessed only within the class even "child" classes do not have access to private members, fields etc.
No.
In C++, the private specifier means that the item can only be accessed by methods of the class, not including methods of derived classes. Protected, on the other hand, means the item can be accessed by methods of the class, and methods of derived classes. Public, to complete the explanation, means that the item can be acessed by any method, this class, another class, or otherwise.
C++ does not have a built-in kilometre class. If you have such a class, it was provided for you by a third party. However, your IDE should be able to show you the members, including private members. I'd imagine such a class would have a private float or double member to store the actual number of kilometres it represents, and perhaps some public methods to convert the number to other formats, such as millimetres, centimetres, miles, yards, inches, etc.
An object in C++ is an instance of a C++ class.