Results 1 to 4 of 4

Thread: Attributes protected in a hierarchy of classes

  1. #1
    Join Date
    Aug 2009
    Posts
    51

    Attributes protected in a hierarchy of classes

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

  2. #2
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Attributes protected in a hierarchy of classes

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

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

  3. #3
    Join Date
    May 2008
    Posts
    685

    Re: Attributes protected in a hierarchy of classes

    @KALIDA, 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.

    @void, it is a show you how this makes the code more robust rather than say it does. Between accessories make and 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 a member isolation.

  4. #4
    Join Date
    Nov 2008
    Posts
    1,054

    Re: Attributes protected in a hierarchy of classes

    For completeness, I would add:

    The C++ offers a range of tools.

    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. Replies: 5
    Last Post: 24-07-2011, 10:31 PM
  2. Unit Hierarchy in Supreme Ruler Cold War
    By Hiller in forum Video Games
    Replies: 7
    Last Post: 23-07-2011, 10:36 PM
  3. Quality Hierarchy of Bioware games
    By Atticus in forum Video Games
    Replies: 5
    Last Post: 01-07-2011, 07:47 PM
  4. iMac CPU Hierarchy?
    By Paqway in forum Motherboard Processor & RAM
    Replies: 5
    Last Post: 25-10-2010, 09:46 AM
  5. Call hierarchy of procedures
    By ArunJ in forum Software Development
    Replies: 4
    Last Post: 06-02-2009, 07:43 PM

Tags for this Thread

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
  •  
Page generated in 1,714,034,313.96403 seconds with 16 queries