0

左派ヒープのコードをコンパイルしていて、levelorder トラバーサル関数をステップ実行したいと考えています。ただし、「theheap.levelorder()」でブレークポイントに到達し、「step」と入力すると、gdb はコードを渡します。

-g フラグを指定してコンパイルしていますが、-fno-inline を試しても無駄でした。なぜこうなった?

私のメイクファイルは次のとおりです。

all:LeftistHeap.o lab10.o
        g++ LeftistHeap.o lab10.o -g -o lab10

lab10.o:LeftistHeap.h
        g++ -fno-inline -g -c lab10.cpp

LeftistMax.o:LeftistHeap.h LeftistHeap.cpp
        g++ -fno-inline -g -c LeftistHeap.cpp

clean:
        rm *.o *~ lab10

編集: levelorder() 関数が 2 つあります。1 つはプライベート、もう 1 つはパブリックです。これはおそらく不要であることはわかっていますが、gdb がこのように動作することはありません。

levelorder は、.h ファイルで次のように宣言されます。

public:
        void levelorder();

private:
        void levelorder(LNode* node);

levelorder は、.cpp ファイルで次のように定義されています。

void LeftistHeap::levelorder()
{
  levelorder(root);
}

void LeftistHeap::levelorder(LNode* node)
{ 
  queue<LNode*> currentLevel, nextLevel;
  currentLevel.push(root);
  while(!currentLevel.empty())
  {
    LNode* temp = currentLevel.front();
    currentLevel.pop();
    if(temp)
    {
      cout << temp->key << " ";
      if(temp->lchild != NULL)
        nextLevel.push(temp->lchild);
      if(temp->lchild != NULL)
        nextLevel.push(temp->rchild);
    }
    if(currentLevel.empty())
    {
      cout << endl;
      swapq(currentLevel, nextLevel);
    }
  }
}
4

0 に答える 0