<oc****@despammed.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi everybody,
the "insert" function of a vector copies the param? or just refers to
the structure?
for example:
typedef struct {
int a;
...
} structType;
void f ( vector <structType> & v){
stryctType xx;
xx.a = 10;
v.add (xx); // it really *copies* xx in v... isn't it?
}
int main(){
f (vect);
cout << vect[0].a;
}
it works, but... is it correct?
Sorry, but the program above neither works/compiles nor is it correct. Among
other things there is no member function add for the class vector, so I
guess you meant something like insert or push_back. These functions do
create a copy which is placed in the container and thus, there is the
requirement that those objects stored in a standard container must be copy
constructible.
HTH
Chris