I'm using VS2010 Ultimate. Having code:
//file IntSet.h
#include "stdafx.h"
#pragma once
/*Class representing set of integers*/
template<class T>
class IntSet
{
private:
T** myData_;
std::size_t mySize_;
std::size_t myIndex_;
public:
#pragma region ctor/dtor
explicit IntSet();
virtual ~IntSet();
#pragma endregion
#pragma region publicInterface
IntSet makeUnion(const IntSet&)const;
IntSet makeIntersection(const IntSet&)const;
IntSet makeSymmetricDifference(const IntSet&)const;
void insert(const T&);
#pragma endregion
};
//file IntSet_impl.h
#include "StdAfx.h"
#include "IntSet.h"
#pragma region ctor/dtor
template<class T>
IntSet<T>::IntSet():myData_(nullptr),
mySize_(0),
myIndex_(0)
{
}
template<class T>
IntSet<T>::~IntSet()
{
}
#pragma endregion
#pragma region publicInterface
template<class T>
void IntSet<T>::insert(const T& obj)
{//BREAKPOINT---------------------------<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/*IF I SET A BREAKPOINT HERE AND AFTER THAT I CHANGE SOMETHING IN THE BODY
I'M GETTING MSG SAYING THAT THE BREAKPOINT WILL NOT CURRENTLY BE HIT, AFTER I REBUILD
THE BREAKPOINT IS VALID AGAIN*/
/*Check if we are initialized*/
if (mySize_ == 0)
{
mySize_ = 1;
myData_ = new T*[mySize_];
}
/*Check if we have place to insert obj in.*/
if (myIndex_ < mySize_)
{
myData_[myIndex_++] = new T(obj);
return;
}
/*We didn't have enough place...*/
T** tmp = new T*[mySize_];//for copying old to temporary basket
std::copy(&myData_[0],&myData_[mySize_],&tmp[0]);
delete myData_;
auto oldSize = mySize_;
m开发者_运维知识库ySize_ *= 2;
myData_ = new T*[mySize_];
std::copy(&tmp[0],&tmp[oldSize],&myData_[0]);
myData_[myIndex_] = new T(obj);
++myIndex_;
}
#pragma endregion
See linke marked as BREAKPOINT. Thanks.
If you change the code while the program is running, the code no longer matches what was compiled, so the debugger is (usually) unable to manage breakpoints until the program is stopped and rebuilt with the new source.
Under some circumstances, Visual Studio supports edit-and-continue debugging where you can edit a file while the debugger is stopped at a breakpoint, then when you resume it will recompile that code and resume with the modified code.
精彩评论