"Do not use pointers, they are slow" does not make sense (at least not in C ++).
This is exactly the same as saying: "Do not use variables, they are slow."
Did you mean "Don't use dynamic memory allocation"?
If so: I don’t think you should worry about it right now. Write the code first, then optimize it later.
Or would you like to say: "Do not use raw pointers (i.e. type foo* )", which will require new and delete ?
If so, this is good advice . Typically, you need smart pointers, such as shared_ptr or unique_ptr , to manipulate objects, not to process the original pointers. You do not need to use new and delete in most C ++ codes, although this may seem natural.
But they are still pointers under the hood!
Or did you mean something else?
Adding
Thanks @ bames53 below for pointing this out:
If transferring a copy is an option (i.e. when you transfer a small amount of data, rather than a huge structure or array that can be larger than several registers, for example, of the order of ~ 16 bytes), do not use pointers (or references) to transfer data; copy a copy instead. This allows the compiler to better optimize this path.
source share