|
-
March 12th, 2008, 09:35 PM
#1
opaque pointer
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
-
March 12th, 2008, 09:45 PM
#2
Re: opaque pointer
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.
-
March 12th, 2008, 10:05 PM
#3
Re: opaque pointer
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?
 Originally Posted by Lindley
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.
regards,
George
-
March 12th, 2008, 10:08 PM
#4
Re: opaque pointer
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."
-
March 12th, 2008, 10:15 PM
#5
Re: opaque pointer
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.
 Originally Posted by Lindley
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."
regards,
George
-
March 13th, 2008, 02:40 AM
#6
Re: opaque pointer
 Originally Posted by George2
Thanks Lindley,
Could you provide a deinite answer (yes or no) whether the wrapper pointer member must point to inner types (structs/classes) please?
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.
Are you planning to implement something using an opaque pointer?
Regards,
Paul McKenzie
-
March 13th, 2008, 02:55 AM
#7
Re: opaque pointer
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.)
 Originally Posted by Paul McKenzie
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.
Are you planning to implement something using an opaque pointer?
Regards,
Paul McKenzie
regards,
George
-
March 13th, 2008, 03:16 AM
#8
Re: opaque pointer
 Originally Posted by George2
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?
And my answer is still the same. It is up to the designer as to what the pointer points to.
Regards,
Paul McKenzie
-
March 13th, 2008, 03:29 AM
#9
Re: opaque pointer
Thanks Paul,
Good to know it is not a must the pointer must be pointed to inner data structores for opaque pointer. :-)
 Originally Posted by Paul McKenzie
And my answer is still the same. It is up to the designer as to what the pointer points to.
Regards,
Paul McKenzie
regards,
George
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|