I heard c++ doesn't let me use array as function's variable since copying all elements in array could be inefficient. So I have to use pointer instead. That being said, is it better to use pointer of certain object as function's variable whenever possible? Or is there any downside of this method?
edit : I know how array is passed in C++. My questions are :
- Is it efficient to use pointer(or reference) when sending class(or structure) object?
- Is there any reason not to use pointer(or reference) every time? I saw lot of code which doesn't use pointer when object is small. I mean it is still extra memory usage, so why don't we use pointer in such cases as well?
I've got the answer of 1st question, so could you please answer second question?