jeudi 4 août 2016

Get pointer to constant from a method as pointer to pointer

I need to get a pointer to a constant from a method. The pointer to constant cannot be returned as return value. What should be the signature of Getpointer method? struct xyz { int x; int y; int z; }; xyz myruntime; void Getpointer(xyz **pz); int _tmain(int argc, _TCHAR* argv[]) { const xyz *ptr = NULL; Getpointer(&ptr); return 0; } void Getpointer(const xyz const ** pz) { *pz = &myruntime; }

Aucun commentaire:

Enregistrer un commentaire