The simplest example of memset I found was at MSDN:
1 2 3 4 5
char buffer[] = "This is a test of the memset function";
printf( "Before: %s\n", buffer );
memset( buffer, '*', 4 );
printf( "After: %s\n", buffer );
I understand what happened, and what happens if I change the last argument of memset, more characters in the buffer will get replaced.
What I don't understand is the purpose of memset, what are the benefits of using it, and most importantly how is it being used in this Identity Matrix function.
I especially don't understand the use of this. I know it's saving to this (current class), but where? The MSDN buffer sample was easy, I'm lost when saving to a class object.
I'm sure my understanding of memset is very incomplete too.
this points to the memory where your current instance of the class is. sizeof(Matrix4x4) returns the size of the structure. that is all what memset needs to start its job: overwritting the memory from the position "this" with the amount delivert from sizeof with a specific value e.g. 0
it is the same like :
1 2 3
for (int i=0; i<iSize; i++)
(*((char*)this)+i)) = 0;
isn't it ugly? ^^
typeconversion is a special topic in c++
don't convert your types like I did above!