BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BDS2006 Bug? "[C++ Error] Unit1.cpp(43): E2024 Cannot modify

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Mon Apr 10, 2006 9:03 am    Post subject: BDS2006 Bug? "[C++ Error] Unit1.cpp(43): E2024 Cannot modify Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.