dynamic memory allocation
i have a problem with allocating memory to an array of class cage, and i need to do this cos i dont know the contents of the file beforehand then reading it into an array of class cage. i don't think i can write cage[i].min_weight or cage[i].max_weight, but what should i do??
Code:
ifstream inClientFile("filename", ios::in);
cage *p;
p=new cage[j];
if(a==0){
for(i=0; i<j; i++)
inClientFile>>cage[i].min_weight>>cage[i].max_weight;
}
}//class cage contains 2 private members min_weight and max_weight. J is the size of the class.
can some kind soul help me with this?? Thanks a million!!