 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon Apr 10, 2006 9:03 am Post subject: BDS2006 Bug? "[C++ Error] Unit1.cpp(43): E2024 Cannot modify |
|
|
I using BDS2006 and stl to writing my code, but the following code
report an strange compile error message:
[C++ Error] Unit1.cpp(43): E2024 Cannot modify a const object
Test Code:
#pragma hdrstop
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <utility>
using namespace std;
//---------------------------------------------------------------------------
#pragma argsused
struct SNegativeBill
{
int ServID;
int RealFee;
};
typedef struct SNegativeBill SNegativeBill;
struct CompareServIDFunctor
{
bool operator()(const SNegativeBill &Item1, const SNegativeBill
&Item2) const
{
return (Item1.ServID < Item2.ServID);
};
};
typedef set<SNegativeBill, CompareServIDFunctor> SNegativeBillSet;
typedef pair<SNegativeBillSet::iterator, bool> SRetCode;
int main(int argc, char* argv[])
{
SNegativeBillSet ServIDSet;
for (int i = 0; i < 10; ++i)
{
SNegativeBill BillItem = {0};
BillItem.ServID = i;
BillItem.RealFee = i + 100;
SRetCode RetCode = ServIDSet.insert(BillItem);
if (!RetCode.second)
{
RetCode.first->RealFee += BillItem.RealFee;
}
}
return 0;
}
//---------------------------------------------------------------------------
as help file say, the insert function:
pair<iterator, bool> insert(const value_type& val);
It is possible BDS2006 BUG? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|