[Dlang Episode 107] Classes - part 1 of N - Reference Type vs Value type (and how ‘ref’ is used)

Поділитися
Вставка
  • Опубліковано 17 гру 2024

КОМЕНТАРІ • 10

  • @bitpilot79
    @bitpilot79 Місяць тому +1

    I am happy that you do videos on OOP in D.

  • @kyleheaser2385
    @kyleheaser2385 Місяць тому +1

    If we pass a 'reference type' by 'ref' and thus a new object will be allocated in func1(), wouldn't the cat1class no longer be pointing to the CatClass allocated in main()? Thereby causing a memory leak.

    • @MikeShah
      @MikeShah  Місяць тому

      D has a garbage collector -- thus it will reclaim that object if there are no longer references pointing to it 🙂

  • @CosmicCoder
    @CosmicCoder Місяць тому +1

    Finally!

    • @MikeShah
      @MikeShah  Місяць тому +1

      Many more lessons to come on D and classes 🙂

    • @CosmicCoder
      @CosmicCoder Місяць тому +1

      @@MikeShah Excellent!!!

  • @bsdooby
    @bsdooby Місяць тому +1

    TBH: I was not aware that members (fields) of classes are public by default in D (?)

    • @MikeShah
      @MikeShah  Місяць тому

      Correct, public to the module. I suspect (though I'd have to verify) this might have been in effort to avoid things like friend functions / friend classes which could otherwise just be defined in the same module.

    • @MikeShah
      @MikeShah  Місяць тому

      Ah, and I found the note here on avoiding friend classes by having things in the same module: dlang.org/articles/cpptod.html