Original Post
Hello, I want to pass a vector to a function as a pointer, manipulate it and pass it back out, but can't get it to work. I have found postings about it on the web but nothing seems to help. This is how my code looks. Simplified. // class.h class hitList { vector names; } // function.h void AddOneNameFunc(vector * names); //function.cpp void AddOneNameFunc(vector * names) { // ...manipulate names } I then try to call the function like so: // class.cpp void hitList::WhenAngry() { AddOneNameFunc(&names); } It compiles and links but when I try and trigger the function it crashes and the XCode debugger kicks in. Strangely(for me), I can get it to work if I do the following. Although I can't do this, I need to use my class variable. void hitList::WhenAngry() { vector tmpNames; vector* pTmpNames = &tmpNames AddOneNameFunc(pTmpNames); } EDIT: I have also tried casting names as, vector* and then passing to function without the '&'. But I still get a crash. Can anyone see what I am getting wrong? Any help appreciated. cheers fred