i know i can initialize like this
std::string foo [3] = {"T1","T2","T3"};
but what if declared it before do i have to initialize each one by its own?
example
std::string foo [3];
foo[0] = "T1"
foo[1] = "T2"
foo[2] = "T3"
i mean giving the string all the values at once foo ={“T1″,”T2″,”T3”}
Technically, you cannot initialise it after the declaration. The nuance is important, because in your second example you assign to the individual strings. Now, you want to assign to the whole array, which doesn’t work. If you used a more intelligent data structure like
std::vectoryou could indeed assign all values in one instruction, because the vector would throw away the old strings and create new ones that would be copy constructed from your"T1",.. strings.