lundi 5 juin 2017

Returning Reference from function of pointer type

Was told today that this was a "clever way of making something like a constructor" but it "sews the seeds of destruction" even though it works. I've been searching and I can't seem to figure out why. Thanks.

Person* makePerson(std::string name, std::int num) {
    Person p(name, num);
    return &p;
}

Aucun commentaire:

Enregistrer un commentaire