Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 349 Bytes

initializer-list.md

File metadata and controls

20 lines (15 loc) · 349 Bytes

Initializer list

Back

Initializing variables can be done with Initializer list in the contructors

class Test {
  int n;
  char c;
  public:
    Test() : n(1), c{'o'} {}
    Test(n) : n(n) {}
    Test(Test& a) : n(a.n) {}
}

Reference