Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

no, you cannot call deleteon something, that is not a pointer, or was not created with new (please dust-off your c++ book, or buy one...)

the destructor for something created in "auto" memory (like above) will get called automatically, once the instace leaves scope, like here:

{ // some scope, e.g. a function
      // allocate a local instance 
      // (and please don't call it SVM, there is already a class with that name..)
      CvSVM svm;
      svm.doSomething();
} // all gone and forgotten

if you want to take over control manually, you will have to use a pointer:

CvSVM * svm = new CvSVM;
svm->doSomething();
delete svm;

no, you cannot call deleteon something, that is not a pointer, or was not created with new (please dust-off your c++ book, or buy one...)

the destructor for something created in "auto" memory (like above) will get called automatically, once the instace leaves scope, like here:

{ // some scope, e.g. a function
      // allocate a local instance 
      // (and please don't call it SVM, there is already a class with that name..)
      CvSVM svm;
      svm.doSomething();
} // all gone and forgotten

if you want to take over control manually, you will have to use a pointer:

CvSVM * svm = new CvSVM;
svm->doSomething();
delete svm;
svm; // NEVER forget to call this !

note, that opencv also has smart pointers:

{ // some scope, again
    Ptr<CvSVM> svm = new CvSVM;
    svm->doSomething();
    svm.release(); // optional
} // if you did not release it before, it will do on its own here

no, you cannot call deleteon something, that is not a pointer, or was not created with new (please dust-off your c++ book, or buy one...)

the destructor for something created in "auto" memory (like above) will get called automatically, once the instace instance leaves scope, like here:

{ // some scope, e.g. a function
      // allocate a local instance 
      // (and please don't call it SVM, there is already a class with that name..)
      CvSVM svm;
      svm.doSomething();
} // all gone and forgotten

if you want to take over control manually, you will have to use a pointer:

CvSVM * svm = new CvSVM;
svm->doSomething();
delete svm; // NEVER forget to call this !

note, that opencv also has smart pointers:

{ // some scope, again
    Ptr<CvSVM> svm = new CvSVM;
    svm->doSomething();
    svm.release(); // optional
} // if you did not release it before, it will do on its own here