bar(const fooRef) declares an immutable address as an argument. bar(const foo *) declares the address of the immutable argument foo as.
For this reason, I prefer option 2. Ie, the presented interface type is one where cv-ness can be specified at each level of indirection. Of course, you can bypass the library of the 1st option library and just use foo , revealing yourself to all kinds of horrors when the library editor changes the implementation. (That is, the writer of the 1st version library only perceives that fooRef is part of the invariant interface and that foo can come, go, be changed, whatever. The 2nd version library writer perceives that foo is part of the invariant interface.)
I am more surprised that no one suggested combined typedef / struct constructs.
typedef struct { ... } foo;
Eric Towers Oct 19 '10 at 4:34 on 2010-10-19 04:34
source share