Hello everyone,
Opaque pointer must be a pointer points to inner (hidden to outside) struct or class?
(refer to the C++ part)
http://en.wikipedia.org/wiki/Opaque_pointer
thanks in advance,
George
Printable View
Hello everyone,
Opaque pointer must be a pointer points to inner (hidden to outside) struct or class?
(refer to the C++ part)
http://en.wikipedia.org/wiki/Opaque_pointer
thanks in advance,
George
This technique can have pointers point to anything. The key observation is that the user of the class must be unable to discern or exploit anything about the inner workings of an object given only a handle to it.
In C, this might be done by handing back a void* which is only casted back to its actual type when it is passed to a function that knows what it is.
Thanks Lindley,
So, not a mandatory requirement for the wrapped pointer member to point to some inner structure? Could be any other global defined structure?
Quote:
Originally Posted by Lindley
regards,
George
It's just a design pattern. Such things don't really have requirements, per se, they're simply useful notions that people have figured out and documented.
"We figured they was more guidelines, than actual rules."
Thanks Lindley,
Could you provide a deinite answer (yes or no) whether the wrapper pointer member must point to inner types (structs/classes) please?
Sometimes I am confused when people use this term.
Quote:
Originally Posted by Lindley
regards,
George
There is no definite answer. The pointer could point to NULL or just an int, or whatever the coder(s) decide it to point to.Quote:
Originally Posted by George2
Are you planning to implement something using an opaque pointer?
Regards,
Paul McKenzie
Thanks Paul,
Sorry I have not made myself understood. My question is, for the opaque pointer design "pattern", the member pointer should be pointed to some inner data structure or global/namespace level data structure or both ok?
(ok I mean whether in this way, it could be called opaque pointer.)
Quote:
Originally Posted by Paul McKenzie
regards,
George
And my answer is still the same. It is up to the designer as to what the pointer points to.Quote:
Originally Posted by George2
Regards,
Paul McKenzie
Thanks Paul,
Good to know it is not a must the pointer must be pointed to inner data structores for opaque pointer. :-)
Quote:
Originally Posted by Paul McKenzie
regards,
George