Question About temlates.

From: Joec (joec_at_annuna.com)
Date: 02/26/04


Date: Thu, 26 Feb 2004 00:39:02 GMT

I am trying to rewrite part of the standard library. Not fully, I am
still new at this, but what I want to do is create a template class that
will act like a dynamic array. I have gotten it to work with integers
but I am having trouble with changing the variables from int to T.

template <class T> class box{

   int size;
   T* parray;

public:

   box();
   box(const box& cbox);
  ~box();
   void put(T add);
   T read(int num);
   int size();
   }

   box::box()
   size = 0;
   T* parray = new T[size + 1];
   }

box::box(const box& cbox){
   cout<<"Copy Constructor...\n";
   narry = new cls;
   int nsize = size;
   *narry = *parry;
   }
   ....

All I want to do is get a given type and store it in a dynamic array.
Where am I going wrong?



Relevant Pages

  • Re: Template class parameter
    ... int main ... Sometimes a template class is defined to have only parameter and no type ... If there is no type information ... The canonical example is a factorial class: ...
    (microsoft.public.vc.language)
  • Re: Template class parameter
    ... int main ... Sometimes a template class is defined to have only parameter and no type ... If there is no type information ... The canonical example is a factorial class: ...
    (microsoft.public.vc.language)
  • Re: sizeof dynamic array
    ... > i would like to know how to calculate the size of a dynamic array ... malloc, ... numbers, uses hard-coded data types in allocation statements, asks ... int main ...
    (comp.lang.c)
  • Re: test for single 1-bit or two consecutive 1-bits
    ... A common way to implement a dynamic array in C is something like ... again I won't guarantee I have the corner cases right): ... As long as the "test" function is cheap and inline-able, ... int test3 ...
    (comp.programming)
  • Facing problem in creating object of derived class (whish is derived from template class) and pushin
    ... void display; ... int main ... Also I want to know Is derived class is also a Template class? ...
    (microsoft.public.vc.stl)