私は比較的複雑なデータ構造を構築しようとしています。私の目標は、テキスト文書から単語を読み取り、その単語といくつかの特定のプロパティをハッシュテーブルにインデックスすることです。表は、構造体のベクトルのベクトルから構成されます(ベクトル<ベクトル> vecName;)。これほど私は運が良かった。各ユニークワードは、ベクトル内のインデックス位置にハッシュされる。ベクトルの2番目の次元(構造体のベクトル)は、読み込み中のファイルに関する情報と、そのファイル内でその単語が見つかった場所を格納します。私が読んだ各ファイルについて、特定の単語が複数回見つかると、構造体の中でカウントが増え、整数の構造体のベクトルは、単語がファイルに格納されているすべての場所の情報を格納します。 構造体のベクトルを持つ構造体のベクトルのベクトルを構築できますか? (はい、実際に)
は私がの支援をしたいと思います2つの項目があります- 誰もが私の提案よりも優れたデータ構造の実装のための提案を持っている場合、私は好奇心が強いです。この巨人の代わりにいくつかの独立したデータメンバーを含むクラスは、おそらくより有用でしょうか?
- コンパイルエラーの原因となっている構文エラーがあるか、単純にベクタークラスがサポートしていない構造体を作成しようとしているようです。
ここにcmpilationエラーがあります。すべての3つのエラーは、構造体の内部の構造体のベクトルを参照してください。
「クラスのstd ::ベクトル>」「theLoc」
「クラスのstd ::ベクトルは>」「theStart」という名前のメンバーを持っていないという名前のメンバーを持っていません
「クラスのstd ::ベクトル>は」という名前のメンバーを持っていない「theEnd」
EboMikeが示唆するように、私は、コードを微調整する場合は、元のエラーが離れて行くが、私はその後、取得:
は、私は別のエラーを取得します編集者が私がハイパーリンクを投稿していると思うので投稿できません。要約は次のとおりです: '' testProps.wordProps :: theWordLocのメンバ 'push_back'のリクエスト:theLoc、非クラス型 'int' *ここに私のコードとダイアグラムへのリンクがあります。
#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>
using namespace std;
struct wordLoc
{
int theLoc; // the location of the word in theFile
int theStart; // the beginning of the sentence
int theEnd; // the end of the sentence
};
struct wordProps // stores word info to be placed in array
{
string theFile; // stores the file where theWord is found
int theCount; // increments with each occurence of theWord
vector <wordLoc> theWordLoc; // stores the wordLoc info for each occurence of theWord
};
int main()
{
int Tsize = 20000;
wordProps testProps;
testProps.theFile = "test1";
testProps.theCount = 1;
testProps.theWordLoc.theLoc.push_back(200);
testProps.theWordLoc.theStart.push_back(1);
testProps.theWordLoc.theEnd.push_back(15);
vector < vector <wordProps> > theWordProps;
theWordProps.resize(Tsize);
theWordProps[0].push_back(testProps);
cout << "index[0] = " << theWordProps[0].front().theFile << endl;
cout << "index[0] = " << theWordProps[0].front().theCount << endl;
cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theLoc << endl;
cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theStart << endl;
cout << "index[0] = " << theWordProps[0].front().theWordLoc[0].theEnd << endl;
cout << "size of theWordProps[0] = " << theWordProps[0].size();
cout << endl;
}
「それは私がコンパイルエラーを引き起こしている構文エラーのいずれかを持っていることが表示されます」...エラーメッセージの全文を投稿してください。 –