well im done with this whole thing thanks for all the help you guys i got it working 100% no problems or anything thanks i learned a lot too.
Type: Posts; User: dotz02x
well im done with this whole thing thanks for all the help you guys i got it working 100% no problems or anything thanks i learned a lot too.
hmm i believe its badwords because when i // it doesnt give me the double free error but i dont see where i deallocate it
well they are both array and yes they both are set to point to something. i had badwords point to a class of badwords which consist of two strings and then i have sentence point to an array of words...
okay so i get a double free fault at the end of my program when i use the sentence.~Setence();
destructor in my program and the destructor contains the following code:
Setence::~Sentence()
{...
all i have now is a double free error at the end of my program when it asks if the user wants to end the program and if he answers true then it does but i get a double free or corruption error and i...
okay thank you i believe it is now fixed
void extend()
{
string *temparray = new string[max_size*2];
for(int i = 0; i < max_size; i++)
{
temparray[i] = sentence[i];
}
delete[] sentence;
max_size = (max_size*2);
sentence = new...
okay this is all within the class
when i try to cout << sentence[i]; in a loop to output each of the words for some reason it displays nothing now....
well okay i figured out that problem but... i have another problem and that is now my sentence array contains no data because the function is in the private section of a class.
If i copy the...
but dont i have to deallocate all memory that has been allocated? or can i do that at the end of my program?
well the function is part of a class and sentence is a private data
the code is set to a function so it can be called more than once.
well this is the code i got going:
string *temparray = new string[max_size*2];
for(int i = 0; i < max_size; i++
{
temparray[i] = sentence[i];
}
delete[] sentence;
sentence = temparray;
well i have another problem now i get a double free error when i try to extend it more than once
but i have one question how do i access a private function declared in a class within a class?
For example:
class Test
{
private:
int size;
string * sent;
void extend() const;
thats what i mean lasterlight hehe my mistake on my wording
Well, thanks for all the feedback but i found my own way to attack this problem and it was by creating a temporary array that is doubled the size, copying the old array to new then deallocating the...
well, the only idea that came to my head is to reinitialize the array.
array = new string[20];
but i am not sure if that works.
I was wondering how do i increase an array size.
Example:
string *array;
array = new string[10];
and I want to increase the elements in that array to 20 how can i go by attacking this...