Instances

Discussion in 'Plugin Development' started by TerroDoor, Nov 27, 2019.

  1. Offline

    TerroDoor

    Hi I’ve got a few questions.
    Whenever I make a new class and use my main as a instance I do the following

    Public main pl;
    Public classname (main instance){
    pl = ins;

    But I want to understand this more, what about if I want to link two classes that are both outside of main? How would I do that


    Sent from my iPhone using Tapatalk
     
  2. Online

    timtower Moderator Moderator

  3. Offline

    TerroDoor

    Could I be linked or shown an example?



    Sent from my iPhone using Tapatalk
     
  4. Online

    timtower Moderator Moderator

  5. Offline

    TerroDoor

    Can I only make an instance of the Main class? How would I make an instance between two classes outside of the Main?

    Eg: Public class One(){ and
    public class Two(){

    Thanks for the link


    Sent from my iPhone using Tapatalk
     
  6. Online

    timtower Moderator Moderator

    @TerroDoor You have 1 instance of the main class.
    Then you give it two fields, one for each class type.
    For those two fields you make getters in the main class.
    Then you can use those getters in the classes.
     
    TerroDoor likes this.
  7. Offline

    robertlit

    This is called dependency injection, google it if you want to understand more.
     

Share This Page