Why do i have to dereference a reference (not a pointer) to access its data (context: used as parameter in STL-algorithm)?
Why do i have to dereference a reference (not a pointer) to access its data (context: used as parameter in STL-algorithm)? I'm writing a programm that's supposed to define classes that represent a sparse matrix (matrix with few non-zero values) and then perform a few operations on a vector of these sparse matrixes. The part where i had to define the classes mostly works (1) and there also already is a working vector of the matrices ("matrixvec") itself. However now i just want to add all the matrices together using the accumulate-algorithm from the STL. This works somewhat, but not really in the way i expected. So basically i give accumulate as an initial value an external matrix called "sammelmatrix" and then accumulate adds every matrix to "sammelmatrix" (using a self-defined +operator (that works in other parts of the programm too). Using this method (instead of e.g. "sammelmatrix = accumulate(...);") i think you would need to pass sam...