Miscellaneous: Reference Qualifiers

code

Syntax

Usage / Usability

  • Member function reference qualifiers make it possible to treat lvalue and rvalue objects (*this) differently.
  • Member functions must not be virtual to use them
  • Member function reference qualifiers make it possible to treat lvalue and rvalue objects (*this) differently.

 

 

Suppose we have a factory function that creates Widgets,

and we want to initialize a variable with the std::vector inside the Widget returned from makeWidget:

 

Leave a comment

Your email address will not be published.