c++ - Using (void*) as a type of an identifier -


In my program, I have objects (of the same class) in which everyone should have a unique identifier with simplicity and performance For, I chose to use the address of the object as the identifier. To keep the types simple, I use (zero *) as a form for this identifier. In the end, I have a code like this:

 < Code> class MyClass {public: typedef void * identity_t; Identity_t id () const {return (zero *) this; }}  

This is working fine, but GCC gives me a link-aliasing warning. I understand that if the ID was used for data transfer then the code would be bad. Luckily it is not, but the question is, will the code generated for adaptation affect it? And how to avoid warning?

Note: I am reluctant to use (char *) , because it will indicate that the user can use the data to copy, which can not do that!

You are violating a logical consta, returning an unstable object in the form of an object.
Outside the form of Neil, no artist is required.

  Class MyClass {Public: Type Kanf Worth * identity_t; Ident_t id () const {return it; }};  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -