   My array is empty when filling it from another class
  Okay, this problem is driving me nuts and I'm sure the solution is simple, but I can't find where it is.I'm calling from some class A to a method in class B which fills an array (or a vector or a pointer, I tried them all) defined as an attribute in B, this method works fine and inside it the array/vector/pointer is correctly filled with my elements. The problem is, when I get back to class B for other operations, the array/vector/pointer is completely empty.I debugged the whole thing but can't find the exact point in which the array is emptied.Any ideas?PD: I'm using C++ under VS2008.PD2: It's not a matter of me explicitly clearing or emptying the array; the only references to it are the moment I fill it with elements, and the moment I read those.PD3: If I call the filling function from inside class B, it seems to be working fine.   
  Post your code and we might be able to spot the error. It sounds like it's a matter of stack allocated containers going out of scope. But it's hard to give a definite solution without knowing your implementation.;  Sounds like you pass the array by value where you should be passing by reference:bad:void foo( std::vector< int > x ) {    x.push_back( 1 );    x.push_back( 2 );    x.push_back( 3 );}good:void foo( std::vector< int > & x ) {    x.push_back( 1 );    x.push_back( 2 );    x.push_back( 3 );}Same for a native array:bad:void foo( int * x ) {    x = new int[3];    x[0] = 1;    x[1] = 2;    x[2] = 3;}good:void foo( int *& x ) {    x = new int[3];    x[0] = 1;    x[1] = 2;    x[2] = 3;}Otherwise, post some code.   ;  Method in class A (CScene):void CScene::initFirstTimeSkeletons(){vector<CSkeleton>::iterator skeleton;for(skeleton = sk.begin(); skeleton != sk.end(); skeleton++){if ((*skeleton).isCreated()){(*skeleton).createBoneConstraints();}}}Source of createBoneConstraints in class CSkeleton:void CSkeleton::createBoneConstraints(){bone_contraints.push_back(Constraint(bList[17],bList[16]));bone_contraints.push_back(Constraint(bList[16],bList[24]));bone_contraints.push_back(Constraint(bList[24],bList[25]));bone_contraints.push_back(Constraint(bList[25],bList[26]));bone_contraints.push_back(Constraint(bList[26],bList[27]));bone_contraints.push_back(Constraint(bList[16],bList[19]));bone_contraints.push_back(Constraint(bList[19],bList[20]));bone_contraints.push_back(Constraint(bList[20],bList[21]));bone_contraints.push_back(Constraint(bList[21],bList[22]));bone_contraints.push_back(Constraint(bList[18],bList[14]));bone_contraints.push_back(Constraint(bList[24],bList[14]));bone_contraints.push_back(Constraint(bList[14],bList[12]));bone_contraints.push_back(Constraint(bList[12],bList[3]));bone_contraints.push_back(Constraint(bList[12],bList[8]));bone_contraints.push_back(Constraint(bList[12],bList[1]));bone_contraints.push_back(Constraint(bList[8],bList[9]));bone_contraints.push_back(Constraint(bList[9],bList[10]));bone_contraints.push_back(Constraint(bList[3],bList[4]));bone_contraints.push_back(Constraint(bList[4],bList[5]));bone_contraints.push_back(Constraint(bList[12],bList[8]));bone_contraints.push_back(Constraint(bList[19],bList[24]));bone_contraints.push_back(Constraint(bList[16],bList[14]));bone_contraints.push_back(Constraint(bList[1],bList[7]));bone_contraints.push_back(Constraint(bList[1],bList[3]));}function in class CSkeleton that uses elements in the array:void CSkeleton::drawConstraints(){for(int i=0;i<bone_contraints.size();i++){bone_contraints.at(i).satisfyConstraint();bone_contraints.at(i).draw();}}Out of reference, here is class Constraint:class Constraint{private:float tolerance;public:float rest_distance; CBone *bone1,*bone2;Constraint();Constraint(CBone *p1, CBone *p2);inline CBone* getBone1(){return bone1;};inline CBone* getBone2(){return bone2;};void setRestDistance();void draw();void satisfyConstraint();float calcDistance();};I also found out it's not only a thing of collections, every change I make on those elements calling a function from outside class CSkeleton are not properly "saved". (I.E. I tried creating "Constraints" beforehand, calling from inside CSkeleton, and then initializing some needed values of them from CScene: they are correctly set inside the function, but on getting back on the class Constraint they are again zeroed.   ;  Solved it. My bad. CSkeletons on CScene were not pointers but simple objects.Thanks!   