Share variable between multiple classes

前端 未结 5 1564
囚心锁ツ
囚心锁ツ 2021-01-06 13:11

If i have 3 classes, lets say: Mainclass, ChildClass, OtherChild.

MainClass()
{
     ChildClass cc = new ChildClass();
     OtherChild oc = new OtherChild();         


        
5条回答
  •  梦谈多话
    2021-01-06 14:02

    The easiest answer is most likely that you should simply pass the name along to both child classes, instead of passing it along to one class and then having those siblings talk to each other. When you set the name of ChildClass, just set the name of OtherClass at the same time.

提交回复
热议问题