cob said:
Are there any situations where it might be better to use
struct a { int i };
rather than
int i; ?
Why would one ever do this?
Homework? Good question anyway.
You might to the above if you wanted a type which was 'int-like' but
distinguishable from a normal int in function overloading (for instance).
You might do it is you wanted an 'int-like' type but wanted to suppress some
of the normal behaviour of an int (automatic conversion to double for
instance).
I'm sure you can think of some more cases.
john