samedi 31 octobre 2015

C++ constructor syntax and zero-initialization

This is a short question about syntax in c++:

class arrayInit {
 public:
  bool vars[2];

  arrayInit() : vars() {} //1
};

class array {
 public:
  bool vars[2];
  array() {} //2
};

What does 1 and 2 do?

Why they don't zero initialize like this: bool vars[2]={};?

What is the purpose of arrayInit() : and array()? and what is it called so I could search for it?

It's from: http://ift.tt/1M79HWt

Aucun commentaire:

Enregistrer un commentaire