-2
私はベクトルを作成し、そのベクトルを持つクラスコンストラクタを入力は、それがstd :: vectorを呼び出して使用していますが、std :: vector <double、std :: allocator <double>>が使用されています
undefined reference to Class::Class(std::vector<double, std::allocator<double> >)
クラスは
std::vector<double>
のコンストラクタを持っていなく
std::vector<double, std::allocator<double> >
というエラーを返します。
いくつかのコード例:任意の洞察力が高く評価され
std::vector<double> x1;
std::vector<double> x2;
std::vector<double> myvec;
double thisX;
for (int i=0; i<x1.size(); i++ {
thisX = x1[i];
myvec.push_back(thisX);
}
for (int i=0; i<x2.size(); i++ {
thisX = x2[i];
myvec.push_back(thisX);
}
Class MyClass(myvec);
// has a constructor for std::vector<double>
// compiler throws the undefined reference to
// Class::Class(std::vector<double, std::allocator<double> >)
!私はそれが明らかでないならば、C++には比較的新しいです。
リンカーは、 'std :: vector'をとるコンストラクタの定義を見ませんでした。 'std :: vector'は2つのテンプレートパラメータを持つ* class-template *です。要素型、およびアロケータ型。アロケータはデフォルトのテンプレートパラメータ –
WhiZTiM
です[docs](http://en.cppreference.com/w/cpp/container/vector)をご覧ください。ベクトルには常に2番目のテンプレートパラメータがあります。デフォルトは 'std :: allocator' –
user463035818
です。コンストラクタはどこで定義されていますか? – NathanOliver