Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Question for the C++ gurus
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00368531
Message ID:
00369090
Vues:
19
Charlie,

>Are all pointers created on the heap and regular variables created on stack?

No. If the pointers are object members they wouldn't be on the stack unless the whole object was on the stack.

void Func1( void )
{
SomeClass o;
SomeClass *op;
int i;
}

All of the above variables are on the stack, you have a full object (o), a pointer that would hold a reference to an object, and a plain old int.

You could do:

op = &o; // might have the syntax off a little I don't write C++ everyday now, make op point to the instance of the object o that's on the stack

op = new SomeClass; // allocate a SomeClass object on the heap and point the variable to it
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform