c++ - Is member value in the class initialized when an object is created? -


i'm writing hash class:

struct hashmap {   void insert(const char* key, const char* value);   char* search(const char* key);  private:   unsigned int hash(const char* s);   hashnode* table_[size]; // <-- }; 

as insert() need check if table[i] empty when inserting new pair, need pointers in table set null @ start up.

my question is, pointer array table_ automatically initialized zero, or should manually use loop set array 0 in constructor?

the table_ array uninitialized in current design, if int n;. however, can value-initialize array (and zero-initialize each member) in constructor:

struct hash_map {     hash_map()     : table_()     {     }      // ... }; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -