|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| 3D Game Engine Architecture Chapter 3 |
|
![]() Tim Cowley Member since: 8/30/2003 From: Taupo, New Zealand |
||||
|
|
||||
Quote: ![]() |
||||
|
||||
![]() jamessharpe Member since: 1/6/2003 From: Bristol, United Kingdom |
||||
|
|
||||
Quote: What kind of rubbish is this? The whole purpose of protected methods is so that derived classes have access to internal methods of a base class! Basically all the public methods marked for 'internal use' should in fact be protected methods. |
||||
|
||||
![]() MENTAL Member since: 4/8/2000 From: Herne Bay, United Kingdom |
||||
|
|
||||
| "The issue is that SetParent is called by the Node class when a Spatial object is attached as the child of a node. No other class (or application) should call SetParent. If the method were put in the protected section to prevent unintended use, then Node cannot call the function. To circumvent this problem, Node can be made a friend of Spatial, thus allowing it access to SetParent, but disallowing anyone else to access it. In some circumstances, a Node-derived class might also need access to a protected member of Spatial. In the C++ language, friendship is not inherited, so making Node a friend of Spatial will not make the Node-derived class a friend of Spatial. To avoid the somewhat frequent addition of friend declarations to classes to allow restricted access to protected members, I decided to use the system of placing the restricted access members in public scope, but tagging that block with the “internal use” comment to let programmers know that they should not use those functions." Try reading the whole paragraph. It's refering to the Node class calling a function on the Spacial class, hence if it were protected or private Node wouldn't be able to access it unless you get into the ugly mess of using friends. |
||||
|
||||
![]() jamessharpe Member since: 1/6/2003 From: Bristol, United Kingdom |
||||
|
|
||||
| No the point is that Node derives from Spatial and thus will have access to any protected functions in spatial, and so the function could be made protected. |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|