oop - How to make a method accessable to only one class? -


let's have class top , class bottom. "outside code" can call method of class top, , result in class top accessing class bottom's method. how make sure works way, , nobody other top not try access bottom directly?

here illustration: enter image description here

if i'll make bottom private, top not able access it. if i'll make bottom public, able it. there in between of these two? heard guys draw uml diagrams, there way inforce design right in ide? why? when change?

moving comment real answer on request.

in c#, , i'm pretty sure c++, looks you're looking nested types. msdn.microsoft.com/en-us/library/ms173120.aspx

public class container {     public container()     {          nested nested = new nested();          nested.doit();     }      class nested     {         private container parent;          public nested()         {         }          public nested(container parent)         {             this.parent = parent;         }          public void doit()         {         }     } } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -