Hi Atul,
I think I see now what is causing the confusion! The handle example actually returns a copy of the handle. Nevertheless the handle is actually a pointer to an operating system resource. Thus it is possible that the OS resource, which is owned by the class, can be modified from the outside and thus eventually break the internal state.
When we return a copy of a part of the internal representation it does not count for reveling the internals because modifying the copy will not modify the internal representation. I hope that clarifies the Item 42 issue. I now also get your point about using a simple struct for NodeAddress. As I said, I’ll need to take a look at the references you provided and will reply.
Best regards,
Peter
atul wrote:Dear Peter
I will read Item 42 again and compare notes with what you suggest… Btw, I was referring to the first example ( socket::handle_ ) and our code and not the second one ( exposing the char* )…
—- cheerio atul
