Changed "malloc" to "new" and "free" to "delete". Correction in memcpy : sizeof(*...)