Reputation: 27
#include "RegionsSingleImage.hpp"
#include <iostream>
#include <vector>
using std::vector;
using std::cerr;
using std::cout;
using std::endl;
RegionsSingleImage::RegionsSingleImage(std::string fName){
#ifdef __CVLOADIMAGE_WORKING__
im = cvLoadImage(fName.c_str(), CV_LOAD_IMAGE_COLOR);
#else
im = readImage(fName.c_str(), CV_LOAD_IMAGE_COLOR);
#endif
if(im == NULL)
{
cerr << "Could not read image from " << fName << endl;
assert(false);
}
list = new std::vector<Region *>;
}
RegionsSingleImage::RegionsSingleImage(IplImage *I)
{
assert(I != NULL);
im = cvCreateImage(cvGetSize(I), I->depth, I->nChannels);
cvCopy(I, im, 0);
list = new std::vector<Region *>;
}
RegionsSingleImage::~RegionsSingleImage()
{
if(list)
for(unsigned int i=0; i< list->size(); i++)
if(list->at(i))
delete(list->at(i));
delete(list);
cvReleaseImage(&im);
}
I need to make my destructor virtual as it deals with abstract objects however I'm not sure where I can put the 'virtual' keyword or how to organize the code based on the layout. Thanks for the help!
Upvotes: 0
Views: 93
Reputation: 56557
You put the virtual
keyword in the header declaration "RegionsSingleImage.hpp"
.
Upvotes: 1
Reputation: 133577
You just need to declare it as virtual
, eg
class RegionSingleImage {
..
virtual ~RegionSingleImage();
}
Mind that this must be done on the first object of the hierarchy for which you are going to store pointers around, and only for it since it will be implicitly virtual in any subclass (as with every virtual
method).
Upvotes: 1