string *level_two;
I got this array declared in the class. I allocated its size dynamically in a class function.
level_two = new string [size];
I need to change its size mainly increase the size retaining the contents, like if size was 5 and my array is declared dynamically as size of 5 and has some string at location 2 and location 3 I want to increase the size of it to 10 depending upon change in size where the strings at location 2 and 3 should be there too without change.
How can I achieve that?
PART II:
int temp=0;
temp= final_hash_index_one;
final_hash_index_one = sum % number_of_keys_to_be_hashed;
sum = 0;
cout<<"final_hash_index_one: "<<final_hash_index_one<<endl;
if(final_hash_index_one>temp)
{
string *tmp = new string[final_hash_index_one+1];
std::copy(level_two, tmp, final_hash_index_one+1);
delete [] level_two;
level_two = tmp;
}
if(temp>final_hash_index_one)
{
string *tmp = new string[temp+1];
std::copy(level_two, tmp, final_hash_index_one+1);
delete [] level_two;
level_two = tmp;
}
level_two = new string [final_hash_index_one+1];
level_two[final_hash_index_one] = file_se_uthao;
tab_obj[return_structure_index].z = level_two;
new. As @Oli answered, you'd be better with std containers.