I want to add an element to a C++ STL vector and then return its address. Perhaps that is not "safe" or possible? If it is a reasonable thing to do, I am not having any luck.
struct myStruct{...};
myStruct *myMethod() {
myStruct myS(...);
myVector.push_back(myS);
// I cannot get the following line or any variant thereof to compile
myStruct *foo = myVector.rebegin(); // or .rend()-1; or &myVector.rebegin();
return foo; }
As I say, is what I want to do illogical or illegal, and if not, how do I do it? I don't want to use the address of myS because it is on the stack, and I can't make it static because I re-parametize it each time through the method.
Thanks, Charles