7
私は単純なMatrixクラスを作成しています。 私はそれが整数型C++:クラスメンバで名前の付いていないテンプレートパラメータを使用するにはどうすればよいですか?
#include <string>
#include <vector>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_scalar.hpp>
template <typename T, typename = typename boost::enable_if<boost::is_scalar<T> >::type>
class Matrix
{
public:
Matrix(const size_t nrow, const size_t ncol);
private:
const size_t nrow_;
const size_t ncol_;
std::vector<std::string> rownames_;
std::vector<std::string> colnames_;
std::vector<T> data_;
};
で使用されていることを確認するために、名前のテンプレートパラメータを追加しようとしている私は、クラス定義の外で、次のエラーを返し++
template <typename T,typename>
inline Matrix<T>::Matrix(size_t nrow, size_t ncol)
: nrow_(nrow),
ncol_(ncol),
rownames_(nrow_),
colnames_(ncol_),
data_(nrow_*ncol)
{};
グラムをコンストラクタを定義したいと思います
Matrix.hh:25:50: error: invalid use of incomplete type ‘class Matrix<T>’
inline Matrix<T>::Matrix(size_t nrow, size_t ncol)
この問題の解決方法をご存知ですか?
ありがとうございます。
「外部を定義する」とはどういう意味ですか? cppファイルですか? – Garf365
ヘッダーに、クラス定義を終了するカンマの直後にありません。 –