Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-10-2009
Member
 
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?
Reply With Quote
  #2  
Old 15-10-2009
Member
 
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.
Reply With Quote
  #3  
Old 15-10-2009
Member
 
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.
Reply With Quote
  #4  
Old 15-10-2009
Member
 
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!).
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Attributes protected in a hierarchy of classes"
Thread Thread Starter Forum Replies Last Post
Can?t find the hierarchy in Supreme Ruler Cold War Statuser Video Games 5 24-07-2011 10:31 PM
Unit Hierarchy in Supreme Ruler Cold War Hiller Video Games 7 23-07-2011 10:36 PM
Quality Hierarchy of Bioware games Atticus Video Games 5 01-07-2011 07:47 PM
iMac CPU Hierarchy? Paqway Motherboard Processor & RAM 5 25-10-2010 09:46 AM
Call hierarchy of procedures ArunJ Software Development 4 06-02-2009 07:43 PM


All times are GMT +5.5. The time now is 09:38 AM.