answersLogoWhite

0


Best Answer

yes it is possible to make a private class in C++ but this class will not solve any purpose.................

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

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.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you make private class in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the use of private constructor in c plus plus?

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.


Which C plus plus keyword allows a function outside of a class to access private class members?

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.


Difference between private and protected specifier in c plus plus language?

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.


What are the private data members of kilometer class in c plus plus?

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.


How does a class in c plus plus enforce data encapsulation?

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.

Related questions

How do you create a class in C plus plus?

class class_name { private: data_members; public: member_functions; };


What is private specifier in c plus plus?

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.


What if you declare public members rather than private in c plus plus?

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.


What is the use of private constructor in c plus plus?

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.


What is the difference between public and private in c plus plus?

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.


Do the memory will be created for both private and public data members if the object is created for a class in c plus plus?

Yes.


Which C plus plus keyword allows a function outside of a class to access private class members?

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.


What are the difference between public and private inheritance in c plus plus?

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.


Can a c plus plus class be derived from a Java class?

No.


Difference between private and protected specifier in c plus plus language?

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.


What are the private data members of kilometer class in c plus plus?

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.


What is the role of object in c plus plus?

An object in C++ is an instance of a C++ class.