C++ プログラムで、開発中のクラスでテンプレートを使用しようとすると、コンパイラがソースで宣言されたクラス コンストラクターを登録しません。
テンプレートを削除すると問題なくコンパイルされますが、それ以外は、過去 1 時間で間違っている可能性がある点で進歩がありませんでした (テンプレートを宣言する場所と方法、および名前空間の構文を試してみました)。
では、C++ について何が理解できていないのでしょうか。
rondel.h:
template <typename T>
class RondelGauge: public sf::Drawable, public sf::Transformable {
private:
//No Default constructor
RondelGauge();
//Used to draw the gauge
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
//The data the gauge visualises
T& dataValue;
std::string& label;
std::string& dataUnit;
[Irrelevant code emitted]
public:
//The constructor - No errors thrown in the header.
RondelGauge(T& value, std::string& iLabel, std::string& iUnit);
};
ロンデル.cpp:
#include "rondel.h"
#include "stdafx.h"
template <typename T>
//This, and variations of it, fail to reguister.
RondelGauge<T>::RondelGauge(T& value, std::string& iLabel, std::string& iUnit) : dataValue(&value), label(&iValue), dataUnit(&iUnit) {
setOrigin(65 / 2, 65, 2);
setPosition()
}