dimanche 25 mars 2018

Class POD member variable initialization

Regarding the following two ways to initialize the POD member members variables:

class Trie {
  Trie()
    : isWord_(false)
  { }


  vector<Trie *> child(keyLength);
  bool isWord;
};

// OR 

class Trie {
  Trie();

  vector<Trie *> child(keyLength);
  bool isWord = false;
};

Are the two equivalent (performance wise, generated code size wise, etc)? Is there a current preference?

Thank you, Ahmed.

Aucun commentaire:

Enregistrer un commentaire