Skip to main content Link Search Menu Expand Document (external link)

toString Log Quiz

Question

Why is the log output changed after adding the toString function?

Because __traits(allMembers) also matches methods

Correct!

Because toString is always called due to being const

As its name implies, __traits(allMembers) matches all members of a structure / class. This also includes methods, constructors, destructors etc. Follow the example in the documentation

Because toString is called when creating the Boss object

As its name implies, __traits(allMembers) matches all members of a structure / class. This also includes methods, constructors, destructors etc. Follow the example in the documentation