Right now, myVector is declared like this.
Code:
std::vector<Testing> myVector;
And this segment of code is not doing what you expected..
Code:
void Sample::sampleMethod(string myValue) {
Testing *t; //create an new Testing object, t, on the heap
t = new Testing();
t->setValue(myValue); //set the value of t
myVector.push_back(*t); //put COPY OF VALUE POINTED BY t into a vector
} // and t is permenantly leaked here
Value types cannot be deleted (or perhaps they can, but it requires operator delete overloaded.. and I see no reason to do it). That probably confusing note aside, if you are going to use dynamic memory with the vector, you need to declared a vector of pointers, not a vector of value types.
The code then becomes
Code:
// in class declaration
std::vector<Testing*> myVector;
void Sample::sampleMethod(string myValue) {
Testing *t; //create an new Testing object, t, on the heap
t = new Testing();
t->setValue(myValue); //set the value of t
myVector.push_back(t); //put t into a vector
}
// and your destructor works as expected
It should be fine after you do that.