1 | initial version |
There two meanings to const pointer: pointer itself is constant or pointed value is constant. It depends on location of const key-word (before or after asterisk). In this case the pointer itself is not constant (you see it changing). But the values it points to are constant so you can't alter them by mistake while you are working with them. I recommend you to read more about const in C++. This is important and not trivial issue.
step between following lines in given in bytes. If you perform your calculation in the way you described, you will step four time more than required. Notice that cast to float is performed on (mat->data.ptr + row * mat->step) not just (mat->data.ptr).