template <class T, const int> class Data { private: T data; int id; public: Data(); Data(T, const int); virtual ~Data(); }; template <class T, const int x> Data<T, x>::Data() {}
template <class T, const int x> Data<T, x>::Data(T _data, const int _id) { this->data = _data; this->id = _id; } template <class T, const int x> Data<T, x>::~Data() {} template <class T, const int x> Data<T, x>::Data(const Data& other) { //copy ctor } int main(){ jme::Data <std::string, const int> d("data", 1); std::cout << "Hello world!" << std::endl; return 0; } The class above compiles, but when trying to use it in the main() function, I get this error: -------------- Build: Debug in data --------------- Compiling: main.cpp C:\...\main.cpp: In function 'int main()': C:\...\main.cpp:8: error: type/value mismatch at argument 2 in template parameter list for 'template<class T, int <anonymous> > class jme::Data' C:\...\main.cpp:8: error: expected a constant of type 'int', got 'const int' C:\...\main.cpp:8: error: invalid type in declaration before '(' token C:\...\main.cpp:8: error: initializer expression list treated as compound expression C:\...\main.cpp:8: warning: left-hand operand of comma has no effect C:\...\main.cpp:8: warning: unused variable 'd' Process terminated with status 1 (0 minutes, 0 seconds) 4 errors, 2 warnings I am bit confused as to how to use a class like that. _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org https://lists.gnu.org/mailman/listinfo/help-gplusplus