answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between public and private in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between private stafford and plus student loans?

What is the difference between private stafford and plus student loans?


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.


How do you create a class in C plus plus?

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


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.


Does the rest of the public see your private posts you sent to someone on Google plus?

No they don't see it. That is the reason it called private.


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.


Similarities between C plus plus struct and class?

The only difference between a struct and a class in C++ is that struct members are public by default while class members are private by default. Other than that they act and behave in exactly the same way and are both used to define classes. By convention, struct is used exactly as it would be used in C, with all public members and no member functions, to provide backward compatibility with C-style code.


What is the difference between pointers in c and c plus plus?

Nothing.


What is the difference between be plus ing and get plus ing?

There are no such terms in C++.


What is the Difference between trade show and public show?

Trade shows showcase the products or services of a company. Public shows don't necessarily do that. Plus, the former caters to specific clients. Source: http://www.tradegroup.com/


How are children schooled in Israel?

Israel has a very good public school system plus private schools.


What is the difference between statements in c plus plus charconstp and char constp?

There is no difference. Both statements are invalid.