Hello everybody ! I am a beginner in C++ so I don't really have a good experience.
I want some help,
I try to create a dynamic array of object (type ELEMENT), I have a problem when I want to delete an object from array (Error 2157)
This is a part of code :
class ELEMENT
{
private :
int id_num;
int nbnr;
int BI;
public :
: void () ................
: ...............
:
};
ELEMENT *T;
/* before calling the next fonction, I allocate a dynamic memory space every time for T by
T = new TAB; because I don't know the exact size of T, I don't know if it's right like this ?
*/
void eval (int nr, int BS)
{
for (int i=0; i< size; i++)
{if (T [i].BI >= BS)
delete T [i]; // I try to delete the object in position (i) and also free allocated memory
// before I tried with delete [] T; doesn't work !
}
}
and the other question, is there any function to get the current size of T.
I tried with SizeOf(T) doesn't give right value.
That's all, thanks for your answers !