C++ newbie question
Results 1 to 6 of 6

Thread: C++ newbie question

  1. #1
    Senior Member
    Join Date
    Nov 2002
    Posts
    339

    C++ newbie question

    How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?

  2. #2
    () \/V |\| 3 |) |3\/ |\|3G47|\/3
    Join Date
    Sep 2002
    Posts
    744
    I'm confused....

    Are you Marshall Cline or James Kanze? Or is this just a coincidence?

    Here is the link.

    7.6] How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?
    Not worth the effort encapsulation is for code, not people.

    It doesn't violate encapsulation for a programmer to see the private and/or protected parts of your class, so long as they don't write code that somehow depends on what they saw. In other words, encapsulation doesn't prevent people from knowing about the inside of a class; it prevents the code they write from becoming dependent on the insides of the class. Your company doesn't have to pay a "maintenance cost" to maintain the gray matter between your ears; but it does have to pay a maintenance cost to maintain the code that comes out of your finger tips. What you know as a person doesn't increase maintenance cost, provided the code you write depends on the interface rather than the implementation.

    Besides, this is rarely if ever a problem. I don't know any programmers who have intentionally tried to access the private parts of a class. "My recommendation in such cases would be to change the programmer, not the code" [James Kanze; used with permission].

    Go Finland!
    Deviant Gallery

  3. #3
    Junior Member
    Join Date
    Sep 2001
    Posts
    23
    use proxy classes

  4. #4
    Senior Member
    Join Date
    Nov 2002
    Posts
    339
    mathgirl im not sure where you found that i was actually asking for a friend of mine, who knows more about c++ then me at this point.i can see how you would think i plagerized or whatever but i assure you its just coincident.thanx for the link though, its very informative.again though sorry for the misunderstanding
    Don\'t be a bitch! Use Slackware.

  5. #5
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    Posts
    1,356
    Declare all your variables/functions/procedures in your class that you do not want to be visible as 'private', and only provide public functions to access/view the ones that you want to see using the 'public' key word.

    /nebulus
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  6. #6
    () \/V |\| 3 |) |3\/ |\|3G47|\/3
    Join Date
    Sep 2002
    Posts
    744
    That's okay, hatebreed, I was just a little surprised when I saw that link. Also, it seemed, by the question you asked that you (or your friend) must already know about making class members private / public.....so, beyond that, I wasn't really sure where to go with that question.

    Go Finland!
    Deviant Gallery

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •