Note that there are some explanatory texts on larger screens.

plurals
  1. POstd::string in struct - Copy/assignment issues?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. CORemember that 'struct' and 'class' *interchangeably* define class-types, with the only difference being public or private default access. (It's a common misconception, even though you didn't directly say you believed this.) This means userdata has a copy ctor even though you didn't explicitly declare one (*all* class-types have a copy ctor), and the compiler-generated one will do a member-wise copy, which calls the copy ctor of each member, and that's how alemjerus's answer below applies. All compiler-generated copy ctors and assignment operators behave member-wisely instead of bit-dumbly.
      singulars
      1. This table or related slice is empty.
    2. COWhen in doubt, write copy constructor and assignment operators for the `struct` or `class`. I prefer not to rely on *hidden* activities of the compiler.
      singulars
    3. CO@Thomas: I completely disagree with that advice. The compiler generates ones do a perfectly good job. Unless you know what they are doing a novice is going to make a mistake, while somebody who does know what they are doing does not need to do anything. So unless the class contains a pointer the default methods are absolutely fine and probably better than a novice could write. Additionally less code means less maintenance costs.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload