There is no situation that the homeless guy should have said ANYTHING to your 4 year old daughter. Yes, your daughter displayed respect, but I would rather my kids know NEVER to talk to people like that (at that age). What you did was right, and that homeless man was WRONG ENTIRELY for speaking to your daughter.