aka “bros: in order to be rich, just don’t be poor.”

  • TehPers@beehaw.org
    link
    fedilink
    English
    arrow-up
    5
    ·
    5 hours ago

    The memory leaks section just feels like an introduction to smart pointers as though they’re some complex concept. Also, the page is showing its age by mentioning the now-removed auto_ptr instead of something like unique_ptr.

    Anyway, scrolling down a little more:

    Why can’t I assign a vector<Apple*> to a vector<Fruit*>?

    This actually comes up in C# with arrays. Copying their example here:

    object[] array = new String[10];
    // The following statement produces a run-time exception.
    // array[0] = 10;
    

    It may have been a design mistake not to make C#'s arrays invariant, though I don’t know the state of that debate today.