#include <iostream>
#include <math.h>
using namespace std;
template<template<short,short,short,int> class Derived>
struct AllocFactor_Core
{
private:
static long double factor_;
static long double calcFactor_(const short mantissa, const short exponent,const short base)
{
return mantissa * ::pow(static_cast<long double>(base),exponent);
}
public:
static const long double getFactor()
{
return factor_;
}
void setFactor(const short mantissa,const short exponent,const short base)
{
factor_ = calcFactor_(mantissa,exponent,base);
}
void setFactor(const long double factor)
{
factor_ = factor;
}
};
template<short Mantissa, short Exponent, short Base = 10, int Tag = 0>
struct AllocFactorScientific : private AllocFactor_Core<AllocFactorScientific>
{
static short base_;
using AllocFactor_Core<AllocFactorScientific<Mantissa,Exponent,Base,Tag>>::getFactor;
//I'm getting an error here saying: error: type/value mismatch at argument 1 in template
//parameter list for 'template<template<short int <anonymous>, short int <anonymous>, short int
// <anonymous>, int <anonymous> > class Derived> struct AllocFactor_Core'|
};
template<short Mantissa, short Exponent, short Base, int Tag>
short AllocFactorScientific<Mantissa, Exponent, Base,Tag>::base_ = Base;
Veuillez vous reporter au commentaire dans le code (3 lignes ci-dessus). Ce qui se passe, c'est que si j'ai la classe AllocFactor_Core en tant que classe standard non-template et quand j'utilise directive j'utilise juste le nom de cette classe, suivi du nom de :: et fnc, mais dès que je déclare AllocFactor_Core et j'essaye de fournir des params pour cela je me trompe d'erreur.Hériter de la classe de modèle
Utiliser '' au lieu de '' en C++! –
rubenvb