Home > Blockchain >  Chain member initializers
Chain member initializers

Time:03-04

Is it possible to refer to class members inside "in class initializers"?

Example:

struct Example
{
  std::string a = "Hello";
  std::string b = a   "World";
};

It seems to work (compiles and runs) but is it ok to do?

CodePudding user response:

This is allowed in default initializers enter image description here

  •  Tags:  
  • c
  • Related