私はこの問題の原因を何日も探し続けてきました。助けていただければ幸いです。
#ifndef SETFRAMENODE_H_
#define SETFRAMENODE_H_
#include <time.h>
class SetFrameNode {
private:
double rate;
time_t timeStamp;
public:
SetFrameNode():rate(0),timeStamp(0){}
SetFrameNode(double rate, time_t timeStamp): rate(rate), timeStamp(timeStamp){
}
virtual ~SetFrameNode(){};
virtual bool operator<(const HeapFrameNode& rhs) const
{
if (this->rate>=0){
if (rhs.rate>=0){
if(this->rate == rhs.rate){
return (this->timeStamp < rhs.timeStamp) ;
}
return (this->rate < rhs.rate) ;
}
return false;
}
return true;
}
time_t getTime(){
return timeStamp;
}
double getRate() const{
return rate;
}
};
class SetFrameTime: public SetFrameNode{
public:
SetFrameTime(): SetFrameNode(){}
SetFrameTime(double rate, time_t timeStamp): SetFrameNode(rate,timeStamp){
}
virtual bool operator<(SetFrameNode rhs){
return (this->getTime() < rhs.getTime());
}
};
#endif
そして、私が問題を抱えている機能は次のとおりです。
class FrameList {
list<FrameNode> pointsList;
time_t timeStamp;
set<SetFrameNode>* frameSetR;
set<SetFrameTime>* frameSetT;
double rate;
public:
FrameList(set<SetFrameNode>* frameSetR, set<SetFrameTime>* frameSetT):frameSetR(frameSetR),frameSetT(frameSetT),rate(0){
timeStamp=time(NULL);
}
virtual ~FrameList(){
list<FrameNode>::iterator i;
PointFrame* ptr;
double oldRate=0;
for(i=pointsList.begin(); i != pointsList.end(); ++i){
ptr=(i->getTrajectory()).deleteFrame(i->getPoint());
if(ptr==NULL){
continue;
}
SetFrameTime newFrameTime(0,ptr->getTimeStamp());
if(frameSetT->find(newFrameTime) ==frameSetT->end()){
throw 98;
}
oldRate=(frameSetT->find(newFrameTime))->getRate();
SetFrameNode newFrameNode1(oldRate,ptr->getTimeStamp());
frameSetR->erase(newFrameNode1);
oldRate =+ ptr->getRateDiff();
SetFrameNode newFrameNode2(oldRate,ptr->getTimeStamp());
frameSetR->insert(newFrameNode2);
SetFrameTime newFrameTime2(oldRate,ptr->getTimeStamp());
frameSetT->erase(newFrameTime);
frameSetT->insert(newFrameTime);
}
}
で「ここからインスタンス化」エラーが発生し、アイデアはif(frameSetT->find(newFrameTime) ==frameSetT->end())
ありますか?frameSetR->insert(newFrameNode2);
ここに完全なメッセージがあります:
make all
Building file: ../Frame.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Frame.d" -MT"Frame.d" -o "Frame.o" "../Frame.cpp"
In file included from /usr/include/c++/4.6/bits/stl_tree.h:65:0,
from /usr/include/c++/4.6/set:60,
from ../Frame.h:12,
from ../Frame.cpp:8:
/usr/include/c++/4.6/bits/stl_function.h: In member function ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = SetFrameTime]’:
/usr/include/c++/4.6/bits/stl_tree.h:1529:38: instantiated from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) [with _Key = SetFrameTime, _Val = SetFrameTime, _KeyOfValue = std::_Identity<SetFrameTime>, _Compare = std::less<SetFrameTime>, _Alloc = std::allocator<SetFrameTime>, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<SetFrameTime>]’
/usr/include/c++/4.6/bits/stl_set.h:605:29: instantiated from ‘std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) [with _Key = SetFrameTime, _Compare = std::less<SetFrameTime>, _Alloc = std::allocator<SetFrameTime>, std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<SetFrameTime>, std::set<_Key, _Compare, _Alloc>::key_type = SetFrameTime]’
../Frame.h:61:38: instantiated from here
/usr/include/c++/4.6/bits/stl_function.h:236:22: error: passing ‘const SetFrameTime’ as ‘this’ argument of ‘virtual bool SetFrameTime::operator<(SetFrameNode)’ discards qualifiers [-fpermissive]
/usr/include/c++/4.6/bits/stl_function.h: In member function ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = SetFrameNode]’:
/usr/include/c++/4.6/bits/stl_tree.h:1267:4: instantiated from ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(const _Val&) [with _Key = SetFrameNode, _Val = SetFrameNode, _KeyOfValue = std::_Identity<SetFrameNode>, _Compare = std::less<SetFrameNode>, _Alloc = std::allocator<SetFrameNode>]’
/usr/include/c++/4.6/bits/stl_set.h:410:29: instantiated from ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename _Alloc::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = SetFrameNode, _Compare = std::less<SetFrameNode>, _Alloc = std::allocator<SetFrameNode>, typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename _Alloc::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<SetFrameNode>, std::set<_Key, _Compare, _Alloc>::value_type = SetFrameNode]’
../Frame.h:69:38: instantiated from here
/usr/include/c++/4.6/bits/stl_function.h:236:22: error: passing ‘const SetFrameNode’ as ‘this’ argument of ‘virtual bool SetFrameNode::operator<(SetFrameNode)’ discards qualifiers [-fpermissive]
make: *** [Frame.o] Error 1