Skip to content

Member initialisation and assignment not the exact same thing. #17

Description

@alexsavio

Hi,

Nice materials! Anyway, I was having a look and found a comment in the section https://github.com/UCL/rsd-cppcourse/blob/master/lessons/03classes.md#defining-constructors.

It says that member initialisation and assignment are the exact same thing. This is not true though. Please have a look at the Item 12 in Effective C++, for example.

Member initialisation through the initialisation list is more efficient and is the correct way of doing it. The member assignment is hiding one step more, which is the initialisation of the string with an empty string. I understand that this is a course for beginners and you might not want to go into deep details, but I wouldn't say they are the exact same thing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions