Passing Object to Class Constructor Problem

I have this weird error that is messing up my program.
When I pass a class object set to an int array and an int the program is not assigning them to the private variables in my class. I know for a fact that in my driver program both the array and int have values assigned to them. When I pass them though, they seem to disappear.

Here is my header:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
    class set
    { 
    public:
        typedef int value_type;
        typedef size_t size_type;
	enum { CAPACITY = 30 }; 
        set( ) {used = 0;}
        set(int [], int);
        size_type size( ) const { return used; }
        value_type data[CAPACITY];      
    private:            
        size_type used;
    };

My implementation:
1
2
3
4
5
6
7
8
9
10
    set::set(int array_input[], int counted)
    {
          used = counted;
          for(int x = 0; x < used; used++)
          {
               data[used] = array_input[used]; //When I run debug, it tells me
		//the problem is here. Now it the program just stops 
		//working as soon as it gets to this point.
          }
    }

My driver:
1
2
3
4
5
6
7
8
    set first(array1, counter_one), second(array2, counter_two), subtraction;
    // The arrays and the counters have values assigned to them in this part of 
    // the program. Both arrays and counters are of type int.

    //The arrays were taken to a file and converted from string to int. This
    //works successfully. 
    //The counters are the size of each corresponding array. I am trying to pass
    //them into the private variable "used" so I can use it in my program. 

Why is my program crashing as soon as it hits my constructor?
Thanks in advance!
Assume that `counted' is 13
You are doing
1
2
for(int x = 0; x < used; used++)
   data[13] = array_input[13];
Last edited on
Ok, I got it to work. Thanks for the help.
Topic archived. No new replies allowed.