If you are looking for a java-like equivalent of a method ArrayList.set(), you can do it more closely with
void setAt(int x, Object_I_madeup o)
{
myVector.at(x) = o;
}
Like the Java version, it vector::at()will throw an exception if the vector is not large enough. Note that this makes a copy of the object (in fact, two, since you also pass the value of the function).
source
share