I'm trying to get used to C++. I want to add an object in a dynamic array each time I read a line from a file without knowing the dimension.
I declared a pointer to array like this:
Rlmr *myArray;
where Rlmr is a class with a public string as id.
Now I read a file line by line and after that I want to add an object to myArray
        index = 0;
        while (fgets(buffer, MAXSIZEBUFFER, fp) != NULL) {
            if(buffer[0] == '#') // Skip comment lines
                continue;
            else {
                sscanf(...);
                index++;
            }
        // At this point I want a new object in the array
        myArray = (Rlmr*) malloc(sizeof (Rlmr) * index);
        // Here I try to call the object constructor by passing the id
        myArray[index-1] = new Rlmr(cBeacId);
        }
I don't understand then the error from the compiler:
error: no match for âoperator=â in â*(myArray+ ((unsigned int)(((unsigned int)index) * 28u))) = (operator new(28u), (<statement>, ((Rlmr*)<anonymous>)))â
What is wrong. And, how could it be done using std::vector. I'd like to understand both ways, thanks.
 
     
     
    