i am making a list template for a tutorial, heres the code:
template<typename t> class list {
int sz;
t elem;
public:
list() : sz(0), elem(new t[0]){ }
list(int i) : sz(i), elem(new t[i]){ }
list(int* i, double val) : sz(i), elem(new t[i])
{
for(int i=0;i>sz;i++) elem[i] = val;
}
list operator[](int i){ return elem[i]; }
int size(void){ return sz; }
};
and when i call it like this:
list<double> temps(5, 5.0);
it gives me this error:
c:\documents and settings\tom\my documents\visual studio 2008\projects\c++ tutorial\c++ tutorial\main.cpp(9) : error C2664: 'list<t>::list(int *,double)' : cannot convert parameter 1 from 'int' to 'int *'
with
[
t=double
]
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
and when i use the C-style cast, it gives me 6 other errors.
any help would be appreciated:)