> > I havea program which on execution gives unpredictable behaviour (it
shouldn't). In trying to track down the problem, I'm wondering if there
is a difference between these two ways of filling a std::vector with data:
Method 1:
std::vector<int> v;
int k;
for(i=0;i<n;i++){
k = i + 3;
v.push_back(k);
}
Method 2:
std::vector<int> v;
for(i=0;i<n;i++){
int k = i + 3;
v.push_back(k);
}
The only difference with these two methods is the scope of k but this
doesn´t affect the behavior in this case. Please post your real code which
gives you trouble.
I haven't been able to track down the problem yet. However, the only
difference between an older version which worked, adn this version is the
following data structures:
std::vector<PolyTypeClass*> PolyTypes;
class PolyTypeClass{
public:
PolyTypeClass();
virtual ~PolyTypeClass();
const PolyTypeClass& operator= (const PolyTypeClass& poly);
void Copy(PolyTypeClass * pCopy);
int ID;
std::vector<BasePolygonClass> Rot;
};
class BasePolygonClass{
public:
BasePolygonClass();
BasePolygonClass(int Size);
virtual ~BasePolygonClass();
const BasePolygonClass& operator= (const BasePolygonClass& poly);
void Copy(BasePolygonClass * pCopy);
std::vector<PointPropClass> Points;
double Area;
double Length;
double Height;
BOOL IsConvex;
double Angle;
BOOL XFlip;
BOOL YFlip;
};
class PointPropClass
{
public:
PointPropClass();
virtual ~PointPropClass();
const PointPropClass& operator= (const PointPropClass& poly);
void Copy(PointPropClass * pCopy);
BOOL TP;
double Angle;
int Num;
int CavNum;
int St;
int Fin;
int Type;
BOOL Neg;
BOOL IsGhosh;
double x;
double y;
};