Results 1 to 6 of 6

Thread: What is the real use of these Public,Private and Protected in developing a program?

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Answers
    1

    What is the real use of these Public,Private and Protected in developing a program?

    I knew the actual meaning of the visibility labels..but how far these are useful in real programming..whats the use of security with these labels when developing a program..I didnt get the actual use of these labels in basic programs..

    Can anyone explain how far these labels are useful in software companies programming??


  2. #2

    Re: What is the real use of these Public,Private and Protected in developing a progra

    In order to achieve encapsulation..and also preventing the use of data from unauthorized access these specifiers are introduced.


  3. #3
    Contributing Member
    Join Date
    Jun 2010
    Answers
    55

    Re: What is the real use of these Public,Private and Protected in developing a progra

    Think about a class that has to maintain some internal state, like a data structure or a file stream. Allowing other code direct access to that internal state data runs the risk of corrupting the data if that other code doesn't follow the rules for modifying it. For example, if you're writing to a file stream, you don't want to accidentally clobber the file pointer in the process.

    We hide that critical code and data by marking it as private or protected, and provide a public interface that allows other code to update that hidden internal data in a consistent, well-defined manner.


  4. #4
    Junior Member
    Join Date
    Aug 2011
    Answers
    18

    Re: What is the real use of these Public,Private and Protected in developing a progra

    Hi Krishna! I agree wit you,it is done to achieve encapsulation and also to prevent unauthorized access to data.We hide the data using the access points publi,private and protected.


  5. #5
    Junior Member
    Join Date
    Sep 2011
    Answers
    1

    Re: What is the real use of these Public,Private and Protected in developing a progra

    to access data members and member functions with in and out side


  6. #6
    Junior Member
    Join Date
    Sep 2013
    Answers
    4

    Re: What is the real use of these Public,Private and Protected in developing a progra

    In simplified version: It is just to control the access of Data at different level of End Users and Admins.


  7.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact