Results 1 to 4 of 4

Thread: Protected attributes in a class hierarchy

  1. #1
    Join Date
    Jun 2009
    Posts
    57
    Rep Power
    3

    Default Protected attributes in a class hierarchy

    Hello,

    Here I am immersed in the language of C + + Stroustrup and noted that using the keyword protected for attributes in a class hierarchy is banned because taken out of the data corruption. The standard therefore it is to declare all attributes private and set accessors protected if used in subclasses is necessary? If yes why?

    Thank you

  2. #2
    Join Date
    Sep 2009
    Posts
    32
    Rep Power
    0

    Default

    Yes (this is true whatever the language) is the ideal, but it is not enough. We need the accessors do their job i.e. checks the validity of data.

    The goal is to make the wrong change attributes impossible to make the code robust.

  3. #3
    Kenneth Rasmussen is offline Junior Member
    Join Date
    Sep 2009
    Posts
    28
    Rep Power
    0

    Default

    You can give a more precise reference because as you quote, I want to say I do not agree. But I may close on the context that would help a better understanding.

    You still have to show how it makes the code more robust rather than say it does. Between accessors and make more accessible the member, I can not see the difference. I do neither one nor the other; I prefer to provide interfaces with meaning, and therefore doing more than recovering and especially as editing member isolation.

  4. #4
    Join Date
    Sep 2009
    Posts
    30
    Rep Power
    0

    Default

    1. For completeness, I would add:

    The C + + offers a range of tools. Nothing forbids you to take a screwdriver to hammer a nail ... but good.

    We must distinguish several types of inheritance, especially their right. If you've superclass and only willing to provide these attributes in subclass (eg with a manufacturer protected), nothing forbids you to put in some protected -> your class will have a target, provide attributes!

    After it is often of Design Pattern. They each have their good and bad side (and contrary to what some would have us believe, there is no ultimate DP what we can not escape!).

Similar Threads

  1. Metadata attributes in .NET
    By Regina paul in forum Programming
    Replies: 1
    Last Post: 07-22-2010, 10:51 AM
  2. Deleting protected virus
    By TaylorRyan in forum Networking Jargons
    Replies: 2
    Last Post: 02-16-2010, 01:05 PM
  3. Password protected
    By ahnel in forum Windows Vista
    Replies: 0
    Last Post: 01-06-2009, 06:48 AM
  4. Creating protected pages
    By brendin44 in forum Everything Else
    Replies: 0
    Last Post: 12-20-2008, 05:31 AM
  5. Volume Activation 2.0 Technical Attributes.xls User Manual
    By nalk349 in forum Download User Manual
    Replies: 0
    Last Post: 07-31-2008, 01:07 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48