class - Why do C++ classes not have access specifiers like classes in Java have? -
i'm new c++, , i'm familiar java. first thing wondering when started looking @ c++ code classes (not members) don't have access specifiers such private, protected , public. exemples here , here.
public class { // line. private class b { } // not line. } why so?
there's no access modifier @ level of classes, since language has no concept of package. there @ level of data members, member functions , inheritence:
class foo {}; class bar : public foo { public: void bar() const {} private: int bar_(float) {} int a, b, c; }; the closest can declaring nested classes inside class:
class foo { struct bar0 { void bar0() const {} }; struct bar1 { bar0 b0; bar1() { b0.bar0();} }; };
Comments
Post a Comment