Thanks to this post, I'm trying to learning Curiously recurring template pattern.
This is the code I wrote:
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
template<class EnvelopeType>
class Envelope
{
public:
double mSingle = 1.0;
void SetValue(double value) { mValue = value; }
inline double GetValue() { return mValue; }
private:
static double mValue;
};
class Volume : public Envelope<Volume>
{
};
class Pitch : public Envelope<Pitch>
{
};
template<EnvelopeType T>
double Envelope<T>::mValue;
int main()
{
Envelope<Volume> mVolume;
Envelope<Pitch> mPitch;
mVolume.SetValue(0.5);
mPitch.SetValue(1.0);
}
What's wrong? It says unknown type name "EnvelopeType
". Of course it doesn't know: that's the T
type of the template.