Fórumok
Sziasztok!
Lenne a köv. osztálydefiníció (a "..."-tal kihagytam a nem releváns részeket):
template <typename T_>
class BilinearInterp2D {
public:
typedef Eigen::Matrix<T_, 4, 1> CoeffsType;
...
const CoeffsType& getCoeffsAtCell(UInt n);
...
};
Kérdés: hogyan definiáljam a getCoeffsAtCell() függvényt? Ti. erre a definícióra a g++ errort dob:
template <typename T_>
inline const BilinearInterp2D<T_>::CoeffsType& BilinearInterp2D<T_>::getCoeffsAtCell(UInt n) {
return _coeffs[n];
}
Az error a következő:
error: expected initializer before ‘&’ token
Kösz!
- 1293 megtekintés
Hozzászólások
Roviden: a fordito azt hiszi CoeffsType egy valtozo, meg kell neki mondani, hogy tipusnev
template <typename T_>
inline const typename BilinearInterp2D<T_>::CoeffsType& BilinearInterp2D<T_>::getCoeffsAtCell(UInt n) {
return _coeffs[n];
}
http://pages.cs.wisc.edu/~driscoll/typename.html
meg egy kis erdekesseg:
template <typename T>
struct A {
template <typename U>
struct B {};
};
template <typename T, typename U>
typename A<T>::template B<U> * f() { return 0; }
- A hozzászóláshoz be kell jelentkezni