반복 문제가 발생했습니다. 문제는 const 정확성과 관련이 있다고 생각합니다. B :: getGenerate()이 작동하려면이 코드에 대한 const 있어야하지만 B : getGenerate() 통해 제어 권한이없는 가정합니다.C++ const iterator C2662
도움을 주시면 대단히 감사하겠습니다. 사전에
감사합니다, jbu
코드는 다음과 같습니다
int
A::getNumOptions() const
{
int running_total = 0;
BList::const_iterator iter = m_options.begin();
while(iter != m_options.end())
{
if(iter->getGenerate()) //this is the line of the error; getGenerate() returns bool; no const in signature
{
running_total++;
}
}
return running_total;
}
1> \ A.cpp (118). 오류 C2662 : 'B :: getGenerate() : 변환 할 수 없습니다' 이 포인터 'const B'에서 'B &'
의 다른 구성원을 수정하지 않습니다 컴파일러를 알려줍니다. 덕분에 – Arun