C
coder_lol
I put together a quick array template for MS Visual Studio 2003, but I
ran into some trouble. It's been quite a while since I had to roll my
own templates, so I'd appreciate all help.
Example 1
Array<int> *ibuf = new Array<int>(100);
ibuf[0] = 100; //O K
Example 2
String *sptr = NULL;
Array<String*> *locales = new Array<String*>(50);
locales[0] = sptr; // ERROR, WHY?
(*locales)[0] = sptr; // OK, but WHY ???
Example 3 - OK: forward declaration of template class without
including template header.
template<class int8>
class Array;
Example 4 - ERROR: why ??? forward declaration of template class
without including template header.
template<class String*>
class Array;
Thank-you all!
=== ARRAY TEMPLATE ===
template<class T=int32>
class Array : public Object
{
public:
Array(int32 aSize);
virtual ~Array();
int32 length() const;
T& operator[](int32 i);
T *getData() const;
private:
T *data;
int32 size;
};
ran into some trouble. It's been quite a while since I had to roll my
own templates, so I'd appreciate all help.
Example 1
Array<int> *ibuf = new Array<int>(100);
ibuf[0] = 100; //O K
Example 2
String *sptr = NULL;
Array<String*> *locales = new Array<String*>(50);
locales[0] = sptr; // ERROR, WHY?
(*locales)[0] = sptr; // OK, but WHY ???
Example 3 - OK: forward declaration of template class without
including template header.
template<class int8>
class Array;
Example 4 - ERROR: why ??? forward declaration of template class
without including template header.
template<class String*>
class Array;
Thank-you all!
=== ARRAY TEMPLATE ===
template<class T=int32>
class Array : public Object
{
public:
Array(int32 aSize);
virtual ~Array();
int32 length() const;
T& operator[](int32 i);
T *getData() const;
private:
T *data;
int32 size;
};