I have the following destructor and assignment operator
Code:
//destructor
Vehicle::~Vehicle( )
{
if (s != NULL){
std::cout << "destructing " << s << std::endl;
delete s;
}
else
std::cout << "not destructing " << std::endl;
}
// assignment operator
Vehicle& Vehicle::operator=( const Vehicle& other )
{
if( &other != this )
{
s = other.s;
L_ = other.L_;
deltaS = other.deltaS;
}
return *this;
}
problem is it gives me an error of double free, how is this possible?? if s is already deleted previously s would be null and it wouldn't be deleted again... why is this?