Here is my struct (It is in private section of Data-structure class):

 private:
 // this is the main node pointer array to keep
 // track of buckets and its chain.
    struct Node {

  /** member variables */
  unsigned int iCID;
  std::string sVoting_PN;
  std::string sTS[T_LITTRAL];
  unsigned int iCounter[12] = {0};


  /** constructor initializes */
  Node(unsigned int CID, std::string PN, std::string TS, unsigned int counter, unsigned int index ) {
    this->iCID = CID;
    this->sVoting_PN = PN;
    this->sTS[index] = TS;
    this->iCounter[CID] = iCounter[CID] + counter;
}

Node *next;
};
Node* nodeArray[TABLE_SIZE];

I want to initialize all the values of iCounter array to 0. how do i do that?

I tried this one

  unsigned int iCounter[12] = {0};

but it gives me warning, that i have to remove anyhow! Any idea or help is greatly appreciated guys. Thanks in advance.

没有正确的解决方案

其他提示

It worked the other way round. the following line was the problem.

unsigned int iCounter[12] = {0};

After a lot of different tries, finally i got this way of initializing works fine without any warning and error. I am adding this to the answer part, so that someone else having similar problem might get help from this.

struct Node {
Node(): iCID(0), sVoting_PN("") {

  for(unsigned int l=0;l<T_LITTRAL;l++){

    sTS[l]="";
    if(l<AMOUNT_OF_ARTISTS){
      iCounter[l]=0;
    }
  }

}

  //member variables 
  unsigned int iCID;
  std::string sVoting_PN;
  std::string sTS[T_LITTRAL];
  unsigned int iCounter[AMOUNT_OF_ARTISTS]; 

  Node *next;
};
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top