I have a pointer array of Word
(objects) and I have to assign another object of type Word
to this objects array.
Using this two lines of code I put the new object w
inside my objects array (word
).
Word w = Word(new_word, len);
this->word[index - 1] = w;
Then I print my objects array and everything comes out right
for (int k = 0; k < this->len; k++) {
cout << this->word[k].getChars() << endl;
} // End of function 1
After "End of function" we return to the main class that call to another function.
This function print the objects array again but now the function does not print the w
object that I insert in the previous function.
Second function
for (int k = 0; k < this->len; k++) {
cout << this->word[k].getChars() << endl;
} // End of function 2
Can anyone explain to me why this is happening and how it can be arranged.