• bterwijn@programming.devOP
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    1 month ago

    Another common naming convention in C++ is using an underscore as prefix for member variables: int _memberVariable{123};

    • 🇨🇦 tunetardis@piefed.ca
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 month ago

      My personal convention in C++ was to use an m prefix on member variables and a g for class variables.

      I guess in Python, I think of _ as equivalent to protected scope in C++ and __ (double underscore) as equivalent to private. Not a perfect analogy, but it works for me.

      • aion@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        1 month ago

        Just don’t use double underscores in C++, identifiers containing double underscores are reserved for the compiler/linker/standard library.

        • bterwijn@programming.devOP
          link
          fedilink
          arrow-up
          1
          ·
          30 days ago

          Same thing in Python, double underscore prefix triggers “name mangling”. There are issues that can pop up when using it if not aware.