#include #include #include using std::cout; using std::endl; using std::string; //using namespace std; class BackTesting { private: string Name; public: BackTesting(string const & n) { Name = n; cout << "Backtesting of " << Name << " starts" << endl; }; ~BackTesting() { cout << "Backtesting of " << Name << " finished" << endl; }; string GetName() { return Name; }; }; int main() { { BackTesting test1("StackStrategy"); cout << "Backtest " << test1.GetName() << " is running" << endl; } //Destructor is called automatically BackTesting *pBT = new BackTesting("HeapStrategy"); cout << "Backtest " << pBT->GetName() << " is running" << endl; //BackTesting *pBT2 = pBT; //Creating copies may cuase problems int j = 3; if (j == 3) { return 0; //Memory Leaks } delete pBT; //cout << pBT2->GetName() << endl; //delete pBT2; //pBT->GetName();// I have deleted already return 0; }