1. operator placement does not make any difference, it's a style preference as the parser will pick up the preceding and trailing white spaces anyway, so char* s, char *s, char * s are all valid declarations of string s.
2. the more valid way ( at least from a C programmer point of view ) of declaring, allocating and deallocating structure S instance would be with a word struct
struct S { int i; struct S* next; };
struct S* s = new S;
s->i = 0;
s->next = NULL;
delete s;
keyword struct is optional in C++ implemetations ( but again, it is required by C ) so for compatibility sake I always use it ( it's also a good reminder that it is a aggregate type ). If you want to get rid of the keyword struct, but still want to play nice with the C compilers you can create a synonym for your declaration....
typedef struct __S { int i; struct __S* next; } S; // S type is now the same as struct __S
S* s = new S;
s->i = 0;
s->next = NULL; // this is ok as struct __S is equivalent to S
delete s;
3. if your function is declared as
void func1(S* blah) than when calling it you'd pass a pointer to the struct S
void main() {
S *blah = new S;
func1(blah) // blah is a pointer to memory block containing structure S
delete blah; // same here, delete operator takes a pointer to the allocated memory and frees it
}
on the other hand if your function is declared as
void func1(S blah) than when calling it you'd pass a value of struct S
void main() {
S *blah = new S;
func1(*blah) // dereference blah and pass a copy to function func1
delete blah; // this does not change as delete operator still wants a valid address
}
finally usage of the reference operator &, lets say your function is declared as follows
void func1(S* blah) func1 expects a pointer to structure S, but lets say you did not instantiate S as a pointer;
void main() {
S blah;
func1(&blah) // pass the address of blah to func1
// no delete as you did not allocate memory on the heap, but underneath stack memory is being freed to delete the temp objects.
}
hope this helps