Thread: class template Prototype?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    here's a templated class implementing a crude templated array. The class needs to be flushed out to make it useful for anything other than demonstrating the syntax of templated class method definitions, so use it as you may:
    Code:
    template<class T> 
    class Array
    {
      public:
    	T * pT;
    	 int size;
    	 Array();
    	 Array(const Array & rhs);
    	 ~Arrray () {delete [] pT;}
    	 //etc.
    };
     
    template<class T> Array<T>::Array : size(10)
    {
      pT = new T[size];
    }
     
    template<class T> Array<T>::Array(const Array & rhs)
    {
      for(int i = 0; i < size; ++i)
    	 pT[i] = rhs.pT[i];
    }
     
    int main()
    {
       Array<int> fb;
    }
    Last edited by elad; 12-03-2004 at 03:39 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linker error
    By tasha302 in forum C++ Programming
    Replies: 3
    Last Post: 12-14-2006, 12:00 AM
  2. template class default constructor problem
    By kocika73 in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2006, 09:42 PM
  3. Declare a template class as a friend?
    By AH_Tze in forum C++ Programming
    Replies: 11
    Last Post: 05-19-2004, 09:24 PM
  4. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  5. Operator overloading in template classes
    By moejams in forum C++ Programming
    Replies: 5
    Last Post: 07-21-2003, 05:16 PM