When you declare a pointer what is the difference in doing
structure *s = new structure;
delete s;
vs.
structure *s;
I don't understand what the new and delete thing does. Thanks everybody.
When you declare a pointer what is the difference in doing
structure *s = new structure;
delete s;
vs.
structure *s;
I don't understand what the new and delete thing does. Thanks everybody.
In your first example 's' is a variable that holds the address of a 'structure'. 's' points to an instance of 'structure' created on the heap, it contains it's address .
In your second example 's' is a variable that holds the address of a 'structure'. It points to nothing, and doesn't contain a valid address of a 'structure' and so cannot be used to access one.
zen