V
Vasileios
Hello,
I have the following simple class template code:
#include "tinyvector.h"
template<class T, std::size_t M, std::size_t N>
class TinyMatrix : public TinyVector<TinyVector<T, N>, M> {
public:
// constructors
TinyMatrix() {}
TinyMatrix(T s) { assign(s); }
template<typename T, std::size_t K>
TinyMatrix<T, M, K> mult(const TinyMatrix<T, N, K>& m) const
{
TinyMatrix<T, M, K> w(0);
for(std::size_t i = 0; i < M; ++i)
for(std::size_t j = 0; j < K; ++j)
for(std::size_t k = 0; j < N; ++j)
w[j] += (*this)[k] * m[k][j];
return w;
}
};
which is included from a very simple main program:
#include <iostream>
//#include "tinymatrix.h"
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello, World!" << endl;
return 0;
}
when I compile it I get the following error (using gcc-3.72):
In file included from main.cpp:30:
testmatrix.h:12: declaration of `class T'
testmatrix.h:4: shadows template parm `class T'
gmake[3]: *** [main.o] Error 1
gmake[3]: Leaving directory `/home/user/vzografo/test/test'
gmake[2]: *** [all-recursive] Error 1
gmake[2]: Leaving directory `/home/user/vzografo/test/test'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/home/user/vzografo/test'
gmake: *** [all] Error 2
*** failed ***
Do you have any idea why I get this error? And what would be the best
way to correct it?
Thank you
Vasileios
I have the following simple class template code:
#include "tinyvector.h"
template<class T, std::size_t M, std::size_t N>
class TinyMatrix : public TinyVector<TinyVector<T, N>, M> {
public:
// constructors
TinyMatrix() {}
TinyMatrix(T s) { assign(s); }
template<typename T, std::size_t K>
TinyMatrix<T, M, K> mult(const TinyMatrix<T, N, K>& m) const
{
TinyMatrix<T, M, K> w(0);
for(std::size_t i = 0; i < M; ++i)
for(std::size_t j = 0; j < K; ++j)
for(std::size_t k = 0; j < N; ++j)
w[j] += (*this)[k] * m[k][j];
return w;
}
};
which is included from a very simple main program:
#include <iostream>
//#include "tinymatrix.h"
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello, World!" << endl;
return 0;
}
when I compile it I get the following error (using gcc-3.72):
In file included from main.cpp:30:
testmatrix.h:12: declaration of `class T'
testmatrix.h:4: shadows template parm `class T'
gmake[3]: *** [main.o] Error 1
gmake[3]: Leaving directory `/home/user/vzografo/test/test'
gmake[2]: *** [all-recursive] Error 1
gmake[2]: Leaving directory `/home/user/vzografo/test/test'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/home/user/vzografo/test'
gmake: *** [all] Error 2
*** failed ***
Do you have any idea why I get this error? And what would be the best
way to correct it?
Thank you
Vasileios