So I am getting these error messages from Intel (v10) and g++ (v4.1.2) compilers respectively:
"error: the object has cv-qualifiers that are not compatible with the member function. object type is: const element"
"error: passing 'const Tetelement' as 'this' argument of 'void element:setID(long int)' discards qualifiers"But the same code gets compiled using Microsfot VC8.0 compiler with no errors!
After a quick search, I figured that I need to make sure that I am not passing a const object to a non-const function/member.
To my knowledge I am not doing that, here is portion of my code that I think is relevant:
This is the part that invokes the error:
Expand|Select|Wrap|Line Numbers
- std::list<Tetelement> TetMesh::GetSortedElementList() {
- int counter = 0;
- std::set<Tetelement,Tetelm_less>::iteratorit;
- for (it=myelms.begin();it!=myelms.end();++it) {
- (*it).setID(++counter); // error line
- this->sortedtetlist.push_back(*it);
- }
- return this->sortedtetlist;
- }
Expand|Select|Wrap|Line Numbers
- class element {
- public:
- // irrelevant code
- inline void setID(long int idn) { id = idn;}
- private:
- long int id;
- };
- class Tetelement : public element {
- // some code
- };
Now... the following change resolves the error in both compilers:
Expand|Select|Wrap|Line Numbers
- Tetelement temp_tet = *it;
- temp_Tet.setID(counter);
thanks for your time in advance :)