I am working with Visual Studio 2010 and am relatively new to C++. The program I am trying to work with has a class with a parameterized constructor and a destructor in its declaration. Somewhere in the listing, there was a dynamic object array creation using 'new'. However, I faced issues as object array initialization for parameterized constructors is not possible.

I have, thus, tried to implement vectors:

> 
> std::vector< class\_type > my\_object\_array(length, arg); //current attempt
> 
> 
> my\_object\_array = new class\_type[length](arg); //previous code
> 
> 
> 

However, once this object array is created, a ~vector destructor is called and I receive a runtime error of "Debug Assertion Failed... \_BLOCK\_TYPE\_IS\_VALID (pHead->nBlockUse)"

Based on previous such questions on SO, I think this is because of double deletion but I have not called the destructor explicitly during the debugging steps and I still receive this error.

Any help is appreciated! Thanks!

Edit: Added some snippets of the code with names changed.

```
class class_type {
  public:
    class_type(int var1);
    ~Class_type();
    /*

     Member functions

    */
  private:
    int var1;                        
    double var2;                   
    double length;                 
    double width;
    double* arr1;                  
};

```

Constructor definition:

```
Class_type::Class_type(int il){
  length    = 0;
  width     = 0;
  var1    = il;
  var2   = 5;
  arr1 = new double[5];
}

```

Destructor definition:

```
  Class_type::~Class_type(){

  delete [] arr1;}

```

Code where error occurs:

```
int class_type_2::create_my_objects(int num_elem){
   input_value = 10;
   if ( num_elem == 0 ) {
      std::cout<<"Warning!"<<endl;
   } else {
      std::vector<class_type> my_object_array(num_elem, input_value);
      //my_object_array= new class_type[num_elem](input_value);
        } //Debugger doesn't go beyond this step!
   return 0;
}

```