during function calling.which is better pass by value or pass by const reference
and it is said that in c++ function arguements are sent through const referneces.
but what if the situation is like this
if the object is going to be changed inside the function??
It depends.
If you need to pass primitive type, pass by value.
If you need to pass any type, change value, so it would be visible outside — pass by reference
If you need to pass user defined class in read-only mode — use const reference
If you need to make a copy of passed argument — use pass by value: enable use of move semantic for those who want to use it.
For simple variables (ints, doubles, etc), passing by value is fine.
If we're talking about objects, then passing by value is inefficient since the object has to be copied onto the stack. Therefore, pass by reference is preferred.
it is said that in c++ function arguements are sent through const referneces.
Said by whom? C++ function arguments are passed however you specify in the function.
if the object is going to be changed inside the function?
Then pass by non-const reference (omit the const keyword).