cilu makes a good point. As long as getPlateNumber is public, which it is, you don't need a friend class. That's not the cause of your crash however. Check your pointers when you try to call the function.