0

Hi I am facing trouble with dynamic pointer's as I am getting undefined refrence error. Here is my segmentof code :

void FlyingUnit::addFall( const char* location, int day, int month, int year )
{
    if(fallCount >= MAX_FALLS)
    {
        cout<<"Cannot add MAX_FALLS raggiunti ";
    }
    else
    {

        falls[fallCount].setLocation(location); //Dynamic pointer problem
        falls[fallCount].setDay(day);
        falls[fallCount].setMonth(month);
        falls[fallCount].setYear(year);
        fallCount++;
    }

}

void Fall::setLocation(const char* location)
{
    if( this->location != nullptr )
    {
        delete [ ] this->location;
    }

    this->location = new char[ strlen(location)+1 ];
    strcpy( this->location, location);  
}
NathanOliver
  • 171,901
  • 28
  • 288
  • 402
Anmol
  • 91
  • 1
  • 3
  • 10

0 Answers0