Can i make a function with a vector<int> parameter instead of an int array?

Recommended Answers

All 4 Replies

Can you help me with the implementation of this function?

It's no different than making a char or int function, just make sure the return type is the same. If you are talking about using a vector as in input for a function, just declare it like you would any other variable.

the vector class have a copy constructor automatically do what you
worrying about. But the original vector never changes. It creates a new
vector<int> and copy the previous contents to it and after the function
returns that newly created vector will be destroyed.

so use this with caution . and when copying the whole vector to new vector , there will be a huge performance problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.