特定のリンクリストにエンティティが存在するかどうかを確認しようとしています。これは私のコードです:
bool LinkedList::existByID(int ID)
{
//create node to search through the list
Node * helpNode;
//start it at the top of the list
helpNode = head;
if (head == NULL)
{
return false;
}
//while the item has not yet been found
while ((helpNode->data->indicatedEntity->getID() != ID) && (helpNode->data != NULL))
{
if (helpNode->data->indicatedEntity->getID() == ID)
{
//return true - the data exists
return true;
}
else
//if the data has not been found, move on
helpNode=helpNode->next;
}
//if the data has not been found and the end of the
//list has been reached, return false - the item does
//not exist
return false;
}
「問題行」としてマークした行から、ifステートメントの部分
(helpNode->data != NULL)
エラー CXX0017 (シンボル "" が見つかりません) およびエラー CXX0030 (式を評価できません) が発生します。
このコードは、リンクリストにエンティティがない場合、つまりヘッドが null の場合に機能します。
Node コンストラクターは次のようになります。
LinkedList::Node::Node()
{
next=NULL;
data=NULL;
}
私も次の行で試しました:
(helpNode != NULL)
および Node コンストラクター
LinkedList::Node::Node(){}
すべての組み合わせで同じエラーが返されます。助言がありますか?