Why is a vector in C passed as a parameter by reference?

Asked

Viewed 40 times

0

Why all other types of variables passed as a parameter to a function are passed by value and the vector does not?

1 answer

2


All data types are passed as arguments by value to the parameter.

The vector is given that it holds a pointer, this is the value of it. The pointer points to another object in another memory position, then you pass the value that is a pointer, and the pointer feature is to stick another pointed object. The passage of argument does not change anything, the way to access the object is changing, are different mechanisms. The access to the object will be by reference, but it is so even without the passage of argument.

Conceptualizing each thing right, it’s easier to understand.

See more in:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.