Say you had a program that was going to pass an argument to a function that was quite large(pass-by-value), lets just say an objet for now. Would it be faster to pass it and just use it as is, or pass a pointer to that object and copy the contents of the pointed to object to a new object inside the function?
I think the answer to this question is no, but is there any way of telling if a function call came from another fucntion or from main()?
1. If you're going to copy the object anyway, you may as well pass it by value. There's no difference.
2. No. Not unless you pass a parameter to tell the function the caller. Something like function("this_function");
This is very rarely used. I think the most common case would be function() being an error report function, and you want it to log/print/whatever exactly where the error occurred.