c++ - How is data actually hidden in a class? -


 class student  {    private :      int rollno;      char name[20];   public:      void change_stud()      { cout<<"enter new roll no:";        cin>>rollno;        cout<<" new name ";        cin.getline(name,20);      }     void show_student()       { cout<<rollno<<"  "<<name;}  } 

now, please explain how roolno , name hidden members of class when can see or change them outside function example main()

int main() {   student s1;   s1.change_stud();   s1.show_student(); } 

what fundamental meaning of data hiding , abstraction in class ? when can access private members of class.

please check - http://www.parashift.com/c++-faq/encap-is-for-code-not-people.html

i think misunderstanding what's meant hiding or encapsulation. it's mean protect against accidentally modifying private member - can using public functions. doesn't member totally not accessible. nor way protect secrets.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -