The above is just an example in my actual code I am passing 6,7,8 vectors to a function with longer names. My question is for the sake of efficient coding and readability should I use typedef and instead of using:
std::vector<int> &vec1
use
vi &vec1 //vi = vector int from type def
so my function would look like
void function(vi &vec1, vi &vec2, vi &vec3)
or is there a way to pass multiple variable names of the same variable type at once , thanks :)
for the sake of efficient coding and readability should I use typedef
It's all a matter of style and clarity to the reader. If using vi as a shorthand for std::vector<int> is clear in your code, then I see nothing wrong with using it.
I think the choice of the name vi to stand for a vector of ints is quite clear.
is there a way to pass multiple variable names of the same variable type at once
No
edit: After seeing MiNiPaa's response, I would clarify by saying "Not as separate arguments".
Because each vector contains unique values that need to be present at all times, I have multiple functions that each process the values differently and I don't want to use global variables so I pass them from the main function to the other functions. It works perfectly but I was just wondering if there was a shorter way of writing each individual variable to the function.
Looks as if using typedef will be the solution, its only going to be me coding it but I also love looking at neat efficient code for my own sake, just wondering if its seen as "incorrect" to do so :)
Possibly! I havent done any work with structs yet (still learning) , would you be able to give me a brief overview of how a struct works and how they could be implemented in this situation? (I will research in depth later today)