I simply don't get why the destructor is being called when the object is passed as a parameter to a constructor of another class. This is the part of code where the problem shows up:
Ocean* sea=new Ocean(4,3,7);
sea->print();
RunLengthEncoding* s2= new RunLengthEncoding(*sea);
sea->print();
the code of the constructor:
RunLengthEncoding::RunLengthEncoding(Ocean sea)
{
oceanEncoding = new MyLinkedListD();
height = sea.height();
width=sea.width();
starveT=sea.starveTime();
int length=1;
int cellType=sea.cellContents(0,0);
int hunger=sea.sharkFeeding(0,0);
for(int row=0;row<height;row++){
    for(int col=0;col<width;col++){
        if(row==0&&col==0){
            cellType=sea.cellContents(col,row);
            hunger=sea.sharkFeeding(col,row);
        }
        else{
            if(sea.cellContents(col,row)==cellType && ((cellType==Ocean::SHARK && hunger==sea.sharkFeeding(col,row))|| cellType!=Ocean::SHARK)){
                    length++;
            }
            else{
                oceanEncoding->add(cellType,length,hunger);
                cellType=sea.cellContents(col,row);
                length=1;
                hunger=sea.sharkFeeding(col,row);
            }
        }
    }
}
oceanEncoding->add(cellType,length,hunger);
internalPointer=oceanEncoding->getHead();
check();
}
 
     
     
     
    