Because the members ptr1 and ptr2 of M are pointers, that haven't been initialised - so they currently contain random values
pointers are addresses to things - those things need to be allocated, or already existing, before their address can be used
A Beginner's Guide to Pointers[
^]