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.
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.
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; }
C: there are no methods in C. C++: no.
I see no reason why you can't do that. The question must be mis stated. Please clarify, and show your code.
c is procedure oriented and c++ is object oriented & much newer.
class class_name { private: data_members; public: member_functions; };
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.
Yes.
struct base1 { // ... }; struct base2 { // ... }; struct derived1 : public base1 // single inheritance { // ... }; struct derived2 : public base1, public base2 // multiple inheritance { // ... };
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.
b+b+b+c+c+c+c =3b+4c
c + c + 2c + c + c = 6c
b + b + b + c + c + c + c = 3b + 4c
To expose an interface to the class members. Without an interface of some kind, an object would be useless.
4c
c + c + c + c + c = 5 * c.
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; }