Array Class GONE WILD!!!

This is a discussion on Array Class GONE WILD!!! within the C++ Programming forums, part of the General Programming Boards category; Every time I try to set one array class type to another, I get an illigal operation. WHY!!!!!???????? Code: template ...

  1. #1
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    920

    Array Class GONE WILD!!!

    Every time I try to set one array class type to another, I get an illigal operation. WHY!!!!!????????
    Code:
    template <class T>
    class array
    {
    public:
    	array(int input_size)
    	{
    		Data = new T[input_size];
    		for(int x = 0; x < size; x++)
    			Data[x] = 0x0;
    		size = input_size;
    	
    	}
    
    	~array()
    	{
    		delete [] Data;
    	}
    
    	T* Data;
    
    	T &operator [] (int index)
    	{
    		return Data[index];
    	}
    
    	int operator = (array other)
    	{
    		for(int x = 0; x < size; x++)
    			Data[x] = other[x];
    		return 1;
    	}
    
    private:
    	int size;
    	
    };
    The other "array" I'm equating it to is of the same type (int). So what's going on?
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    148
    Look here
    Code:
    	array(int input_size)
    	{
    		Data = new T[input_size];
    		for(int x = 0; x < size; x++)
    			Data[x] = 0x0;
    		size = input_size;
    	
    	}
    You set size after the for-loop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  2. Animation class not working
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 03-02-2005, 06:48 AM
  3. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 02:30 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM
  5. Replies: 4
    Last Post: 09-12-2001, 03:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21