I am getting 2 different compiler errors of the following:
AoE2Wide.cpp(1089): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'AoE2Wide::DrsItem' (or there is no acceptable conversion)
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(599): could be 'std::vector<_Ty> &std::vector<_Ty>::operator =(std::vector<_Ty> &&)'
1> with
1> [
1> _Ty=AoE2Wide::DrsItem
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(708): or 'std::vector<_Ty> &std::vector<_Ty>::operator =(const std::vector<_Ty> &)'
1> with
1> [
1> _Ty=AoE2Wide::DrsItem
1> ]
1> while trying to match the argument list '(std::vector<_Ty>, AoE2Wide::DrsItem)'
1> with
1> [
1> _Ty=AoE2Wide::DrsItem
1> ]
The second is different, how would I access this piece of the vector?
1>AoE2Wide.cpp(1100): error C2039: 'Id' : is not a member of 'std::vector<_Ty>'
1> with
1> [
1> _Ty=AoE2Wide::DrsItem
1> ]
I thought this was fixed by making the operator=() that I defined here:
class DrsItem
{
public:
long unsigned int Id;
long unsigned int Start;
long unsigned int Size;
std::vector<char> Data;
DrsItem() {Id = Start = Size = 0;}
DrsItem & operator=(const DrsItem & drs)
{
if (this == &drs)
return *this;
Id = drs.Id;
Start = drs.Start;
Size = drs.Size;
Data = drs.Data;
return *this;
}
DrsItem(const DrsItem & drs)
{
Id = drs.Id;
Start = drs.Start;
Size = drs.Size;
Data = drs.Data;
}
};
class DrsTable
{
public:
long unsigned int Type;
long unsigned int Start;
std::vector<DrsItem> Items;
DrsTable(long unsigned int tp, long unsigned int st, std::vector<DrsItem> itm)
{
Start = st;
Type = tp;
Items = itm;
}
DrsTable() {Type = 0; Start = 0;}
DrsTable & operator=(DrsTable & drs)
{
if (this == &drs)
return *this;
Start = drs.Start;
Type = drs.Type;
Items = drs.Items;
return *this;
}
DrsTable(const DrsTable & drs)
{
Start = drs.Start;
Type = drs.Type;
Items = drs.Items;
}
};
Not sure if this is fixing it or not, or maybe I am doing something 100% illegal, here is the code
AoE2Wide::DrsTable *inTables = new AoE2Wide::DrsTable [tableCount];
for (unsigned long int q = 0; q < tableCount; q++)
inTables[q] = AoE2Wide::DrsTable();
long unsigned int itemCount = 0, tableType = 0, tableStart = 0;
for (unsigned long int q = 0; q < tableCount; q++)
{
inFileDrs >> tableType;
inFileDrs >> tableStart;
inTables[q].Type = tableType;
inTables[q].Start = tableStart;
inFileDrs >> itemCount;
AoE2Wide::DrsItem *itemsArray = new AoE2Wide::DrsItem[itemCount];
for (long unsigned int j = 0; j < itemCount; j++)
itemsArray[j] = AoE2Wide::DrsItem();
inTables[q].Items = *itemsArray; // Error here
}
long unsigned int id = 0, start = 0, size = 0;
for (unsigned long int q = 0; q < tableCount; q++)
{
for (long unsigned int j = 0; j < itemCount; j++)
{
inFileDrs >> id;
inFileDrs >> start;
inFileDrs >> size;
inTables[j].Items.Id = id; // Second error here
inTables[j].Items.Start = start;
inTables[j].Items.Size = size;
}
}