2

index.cpp というファイルに次のメソッドがあります。コンパイルすると、「indexStructure」がこのスコープで定義されていないことがわかります。

#include "index.h"
#include <cctype> // provides isalpha() and tolower()
#include <iostream>
#include <sstream>

using namespace std;

void index::shiftRight (int i)
{
if ( indexSize == (sizeof(indexStructure) / sizeof(indexStructre[0])))
    doubleIndex();

for (int j = indexSize; j > i; j--)
    indexStructure [j] = indexStructure [j-1];
}

index.hに、私は持っています

class index
{

struct node {
    string item;
    int counter;
    int* pageNumber;
};

...

private:
    node* indexStructure;
    int lineCounter;
    int indexSize;

};

型ノードの配列を作成し、それを使用して本の単語を検索するつもりです。なぜ未定義なのですか?

前もって感謝します

4

2 に答える 2

4

のつづりを間違えsizeof(indexStructre[0])ました index::shiftRight()。に修正してindexStructure、もう一度やり直してください。

于 2012-09-26T21:28:16.937 に答える
2

indexStructreここでuは、文字の後に文字がありませんt。ただし、コンパイラが不平を言っていると言っている間、あなたはそれを正しく綴っています:)

于 2012-09-26T21:28:45.723 に答える