Create a vector, pass by value to an object and use it, or use a public vector instance of object?

It is a doubt I have from the beggining og my C++ learning.

I have a main class and I have a object that has the capability of fill a big vector.
What is best :
1
2
3
4
5
Method 1:
Class A:
 create vector;
 call classB passing vector by value (or by pointer ?)(classB fills the vector)
 loop trought vector data.


1
2
3
4
Method 2:
Class A.
  call classB
  loop troughout classB->vector data


Any tip ? Thanks
Last edited on
I'd put it into classB if it should be part of it. (It seems to be like that in this case)

In general terms, what is fast ? Method 1 or method 2 ???

As a general rule, what is best (in terms of speed) :
1.- Create vectors, pass to a classB by ref, use it from class A .
2.- Use the vector from classB ?

And as general rule, what is best for a vector, pass by ref or by pointer ??? (or it is the same?)

Thanks
1.- Create vectors, pass to a classB by ref, use it from class A .
2.- Use the vector from classB ?

How could creating a new vector be faster than using an existing one?

or it is the same?

In terms of speed, it's the same.
Topic archived. No new replies allowed.