I have dynamic array with unknown size, and I need to compare a name of random object in the array, to string that I'm getting from the user, that's mean I need to run all over the array and compare the the string that I have to all the objects in the array. I really don't know how to do this. and idea? I need to run all over files and find some object.
class Folder : public ADFile
{
ADFile** files;
int arrSize;
string filePath;
static Folder*(root);
public:
void addFileToArray(ADFile *);
}
class ADFile
{
string fileName;
tm *lastUpdateTime;
}
void Folder::addFileToArray(ADFile *f)
{
int i;
if (arrSize == 0)
{
files = new ADFile*[1];
files[0] = f;
arrSize++;
}
else
{
ADFile** temp = new ADFile*[arrSize + 1];
for (i = 0; i < arrSize; i++)
temp[i] = files[i];
temp[i] = f;
files = temp;
arrSize++;
}
}
Aucun commentaire:
Enregistrer un commentaire