Witam.
Mam mniej więcej taki kod:
#include <iostream>
#include <vector>
class TestClass
{
public:
TestClass(std::string file_, int x_) : file(file_), x(x_) {}
private:
std::string file;
int x;
};
int main(int argc, char* argv[])
{
using namespace std;
const int end = 100000;
const char *files[] = { "file1", "file2", "file3",
"file4", "file5", "file6",
"file7", "file8", "file9",
"file10",
};
vector<TestClass*> container;
string tmpFile = files[0];
int c = 0;
for (int i = 0; i < end ; ++i)
{
if (i % 10000 == 0)
{
tmpFile = files[c];
c++;
}
container.push_back(new TestClass(tmpFile, i));
}
return 0;
}
Problem w tym, że file z klasy TestClass jest nadmiarowe. Będę miał 10 tyś obiektów klasy TestClass, które będą miały tą samą wartość pola file.
Jak to najlepiej rozwiązać ?