Sorry for my bad english.
Hello i wondering me if i can acces to a parent from it's children. for exemple with a "A" object wherein I create a "B" . It's possible, does this method has disadvantages ? if so what are the solutions?
edit 1: in my case i have a main object which instantiate two objects, a object which handle a database and an other which create view but i want to erase view from database so can i put the main object in the constructor of the view creator class and use the main object function in oder to access to the database and erase the view ? or it is a practice to avoid ?
edit2: sorry for the error, i'm talking about object, not about classes
edit 3: here is an example made by @DaveHowes (thanks to him)
class A {
public void doSomething(){
B b = new B(this);
}
public void doSomethingElse(){
// Do something wondrous
}
}
Class B {
private A par = null;
public B(A parent){
par = parent;
}
public void callMethodInParent(){
par.doSomethingElse();
}
}
P.S: I'm not talking about inheritance.