P
so, habe mich nochmals um das Problem gekümmert!
Habe ein kleines Testprogramm geschrieben und siehe da, es funktioniert einwandfrei!
Hier das Prog:
main.C
#include <iostream>
#include "fe.h"
using namespace std;
int main()
{
FE<2,LAGRANGE> fe; //oder FE<2,XYZ> fe;
unsigned int ret=fe.n_sf(QUAD9);
cout << "Family: " << ret << endl;
return 0;
}
fe.h
#ifndef __FE_H
#define __FE_H
#include <iostream>
#include "macro_elem.h"
#include "enum.h"
template <unsigned int Dim, FEFamily T>
class FE
{
public:
FE();
static unsigned int n_dofs(ElemType);
unsigned int n_sf(ElemType val)
{
unsigned int tmp=1;
tmp = FE<Dim,T>::n_dofs(val);
return tmp;
}
};
template <unsigned int Dim, FEFamily T>
inline
FE<Dim,T>::FE ()
{
printf("Im FE-constructor\n");
}
#endif
fe.C
#include "fe.h"
#include "macro.h"
INSTANTIATE_FE(2);
fe_lag.C
#include "fe.h"
#include "macro.h"
template <unsigned int Dim, FEFamily T>
unsigned int FE<Dim,T>::n_dofs(ElemType val)
{
printf("Ich bin in Lagrange :-)\nElem: %d\n",val);
return 0;
}
INSTANTIATE_MBRF(2,LAGRANGE);
#include "fe.h"
#include "macro.h"
template <unsigned int Dim, FEFamily T>
unsigned int FE<Dim,T>::n_dofs(ElemType val)
{
printf("Ich bin in X :-(\nElem: %d\n",val);
return 5;
}
INSTANTIATE_MBRF(2,XYZ);
macro.h
#ifndef __MACRO_H
#define __MACRO_H
#define INSTANTIATE_FE(_dim) template class FE< (_dim), LAGRANGE>; \
template class FE< (_dim), XYZ>
#define INSTANTIATE_MBRF(_dim,_t) \
template unsigned int FE<_dim,_t>::n_dofs(ElemType)
#endif
enum.h
#ifndef __ENUM_H
#define __ENUM_H
enum FEFamily
{
LAGRANGE=0,
XYZ=5
};
#endif
macro_elem.h
#ifndef __MACRO_EELEM_H
#define __MACRO_EELEM_H
enum ElemType
{
QUAD9=9
};
#endif
Verletzt dies die ODR?