c++ - delete[] pointer being freed was not allocated -


I am using a new operator to create a dynamic allocated array (I'm using this one because I I want to save on memory above the use of a vector) in the error disaster, saying that the indicator was released, although it was clearly. Constructors and destructors are as follows:

  ~ path () {printf ("path destroyer \ n"); If (points) number {delete}; }} Path (const std :: vector & gt; pathpoint & gt; and digits_) {size = points_.size (); Number = new pathpoint [size]; Int i = 0; (Conf. Pathpoints and P: Points_) {points [i ++] = p; } Printf ("path created \ n"); }    

You have to apply:

C ++ standard It says that:

The implicit-fixed copy constructor for a non-union class X copies a member of its subobabs [n 3126 pdf volume 12.8 § 16] < P> Assignment-Contributed Copy Assignment Operator for a non-union class X assigns the copy of its sub-members to the member's rank. [N3126.pdf Section 12.8 § 30]

Then the inherent-defined copy creator and copy assignment operator will not call new for your path / P>

Note:

    < Li> You can also make your type of copy, without the definition of it:

    Example:

      Path (const path and other); // Non-creation-copyable path & amp; Operator = (path & amp;); //   

    (or use)

    • a std :: vector & lt; & Gt; Typical overheads of are very few, there are some references where it really matters: to avoid such problems, use it as much as possible.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -