Forgive me if this has already been asked but the terminology is quite tricky to get right for me. I want to loop over a vector of objects each containing another vector of objects to be looped over in turn. The subvectors/contained vectors need to be able to be modified and not copy constructed or implicitly shared. See the code below. Does this work? If not what’s the best way to do this? Thanks!
class Worker : public QObject
{
public:
void backup();
private:
QVector<BackupJob> jobs;
}
class BackupJob
{
public:
QVector<BackupJob> getSubJobs() { return subJobs; }
private:
QVector<BackupJob> subJobs;
}
void Worker::backup()
{
for (BackupJob& job : jobs)
for (BackupJob& subJob : job.getSubJobs())
//do work on each subjob here
}