の間に違いが表示されていない私には
//---------------------------------------------------------------------------
#ifndef testclassH
#define testclassH
//---------------------------------------------------------------------------
#include <vector>
class TestClass {
private:
std::vector<int> testVect(1); // removing std:: and adding using namespace std; below the include for the vector it still fails to compile;
};
#endif
:ここ
はcomileに失敗した簡単な例でありますそれ自体では「ベクトル」を使用しないでください。 (namespace std;を使用して)おそらくあなたは、より多くのspesificヘルプのための関連コードを貼り付けることができます。
編集:
.hのベクトルを初期化することはできません。おそらくベクトルのresize()関数を使って.cppで行う必要があります。
#ifndef testclassH
#define testclassH
//---------------------------------------------------------------------------
#include <vector>
class TestClass {
private:
std::vector<int> testVect;
public:
TestClass()
{
testVect.resize(4);
}
};
#endif
変更を加える場合は、コンパイルを与えている簡単な例:これは(クラスのコンストラクタを使用して)あなたのためのオプションをすることができます。
あなたの 'testVect'の宣言が間違っています。 '(1)'部分を取り除くには、単に 'std :: vector testVect;'だけでなければなりません。 –