Do you feel it is important to strictly use const every time the value won’t be changed or pass arguments as pointers only when the data will be modified?
I’d like to do things right but if a struct passed as an argument is large in size, don’t you want to be passing the address instead of copying the data? Usually it seems like just declaring the struct argument as an operand is most functional.
//line1 and line2 unchanged in intersect function
v3f intersect( const line_struct line1, const line_struct line2);
//"right" method? Would prefer this:
v3f intersect2( line_struct &line1, line_struct &line2);
is exactly equivalent to
in terms of external behavior, as both hand copies of the lines to
intersect, so the original lines cannot be modified by the function. Only when you implement (rather than declare) the function with theconstform, there’s a difference, but not in external behavior.These forms are distinct from
which doesn’t have to copy the lines because it passes just pointers. This is the preferred form in C, especially for large structures. It is also required for opaque types.
is not valid C.