answersLogoWhite

0


Best Answer

public is an access-modifier that allows you to access methods or properties of a class from outside of the class. A method or property set to protected can only be accessed from within the creating class or subclasses, while a private method or property can only be accessed from within that class

User Avatar

Wiki User

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

Wiki User

15y ago

Any values that are marked as 'public' as a class member are global, and therefore accessible to any code in a c++ program. Since this defeats encapsulation, it isn't a good idea. You want to have the class public members maintain control of what will be allowed for changing class data members, not arbitrary code.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

Public isn't a keyword in C. It's a keyword in C++ to state that members of a class are accessible from outside that class.

This answer is:
User Avatar

Add your answer:

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

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.


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.


Demonstrate single inheritance in C plus plus?

struct base1 { // ... }; struct base2 { // ... }; struct derived1 : public base1 // single inheritance { // ... }; struct derived2 : public base1, public base2 // multiple inheritance { // ... };


Is there anything similar between C and C plus plus with reference to data hiding?

No. Data hiding is a feature of object oriented programming. C does not support OOP, and therefore has no private member access. All members are public in C.


What is b plus b plus b plus c plus c plus c plus c?

b+b+b+c+c+c+c =3b+4c


What is c plus c plus 2c plus c plus c equal?

c + c + 2c + c + c = 6c


B plus b plus b plus c plus c plus c plus c equals?

b + b + b + c + c + c + c = 3b + 4c


Why you use public mode in c plus plus?

To expose an interface to the class members. Without an interface of some kind, an object would be useless.


Symplify c plus c plus c plus c?

4c


What is c plus c plus c plus c plus c?

c + c + c + c + c = 5 * c.


What is an instance class in C plus plus?

You have a class(i.g. MyClass): class MyClass{ public: int MyData; }; And then you use the class like this: int main(){ MyClass MyObject; MyObject.MyData=7; }