samedi 7 mars 2015

C++ set struct attribute to own address


I am somewhat new to C/C++, so lets say I have a simple struct:



struct item {
int* address;
std::string name;
}



  1. Is int* the correct datatype to hold a memory address?


  2. Can I just use something like:



    item i;
    i.address = &i.;

    To set the structs attribute to it's own address?






Aucun commentaire:

Enregistrer un commentaire