I am getting an error - heap corruption, I do not know why
my base:
h:
class base {public: base (four * base names, four * city names); Virtual ~ (base); List & amp; Lt; Vehicle * & gt; :: const_iterator GetEndList (); Zero PrintAllVehicles (ofstream and ResultFile) const; Four * GetBaseName () console; Four * GetLocation () const; Insert Nine New VehicleTobes (Vehicle * NewVehhel); List & lt; Vehicle * & gt; :: const_iterator FindVehicle (four * ID); Zero Extractor (List & lt; Vehicle * & gt; :: const_iterator beg;); Private: Four * m_name; Four * m_location; & Lt; Vehicle * & gt; M_baseVehicles; };
CPP:
base :: base (four * base name, four * city name) {m_name = new four [strlen (baseName) + 1] ; Strcpy (m_name, baseName); M_location = New four [Stellen (city name) + 1]; Strcpy (m_location, city name); } Base: ~ Base () {Delete} M_Name; Delete [] m_location; //m_baseVehicles.clear (); Army Destroyer: Military :: Force () {List & lt; Base * & gt; :: Iterator support = m_basesList.begin (); For (base alters; bachetter! = M_bashus list.and (+; bassist)) delete (* bassist); M_basesList.clear (); }
What am I doing wrong?
If something is not clearly wrong with the code you show, then it is likely that the error code You have not shown in
The most suspicious thing for me is that there are two points in the
objects in the same data, and when they are destroyed, they remove it twice Give, base
class and they do not have to be defined as a per constructor or assignment operator, this means that you will never You should also make a copy of the base
object, you point to two data base
the army
also The problem may also occur (because there are many base
pointers), but you definition of no show class, so it is unclear whether it is a copy constructor and assignment operator.
Finally, you have not shown that the base
is being allocated to the objects. Is it possible that they are being passed in the army
object and that army
has been removed anywhere outside the object? Or maybe the objects contained in the army
object by base *
are being applied on the stack that should not be deleted?
Comments
Post a Comment