lifespan of an object and a class + the object's identity
I am new to making programs, although I can get around windows quite well. I am having a little bit of trouble trying to find out the lifespan of an object and a class. I looked on http://www.cprogramming.com/ , and I spent a couple of hours searching for this on google. While I was doing this search, I came across some websites that used "object's identity" quite a lot. Does anyone know what this means, or could you give me a website that explains the above?
Lets see if I understand you correctly....
So letís see if I understand you correctly. The lifespan would be how long it takes for you to make your bike pedals to make a full turn (or revolution). The scope would be your brain; your brain tells your feet where the bike pedals are and how to use them.
Variables have lifespans and scope. Lifespan tells you how long the object is in existance. Scope tells you where you can access the variable using it's name.
So lets say "new" is invoked. If this command was a bike, then someone has given you a brand spanking new bike. Then the delete command is used. At the same time the delete command is used, someone has stolen your bike and trashed it. (I don't know much about the delete command, but I think I have seen some threads on this, so I can read on what it does.)
Dynamically allocated objects: A variable that is created using new exists from the moment the new was invoked until it's destroyed using delete. Since this object has no name it also has no scope. Any pointer that knows the object's type and location can reference the object.
In case you were wondering, yes, I am new to programming in any language.