What are anonymous structure, unions and what are their uses?

Showing Answers 1 - 6 of 6 Answers

Valentin

  • Jul 2nd, 2007
 

Anonymous structures are not standard C++, therefore they are implemented as extensions.

Anonymous unions are standard C++, and they are can be found inside an object or inside a namespace.

1. When an anonymous union is declared inside of an object the role is to have all data members of that class or struct to share the same memory space and they are accessed as any other datamembers. This is not considered a healthy OO practice and it can be used only with the system that do not have a good support for typecasting. reinterpret_cast is the OO C++ recommended way over anonymous unions.

2. An anonymous union can be declared inside a namespace or at the global scope but because the unions members require internal linkage, the union must be declared static.



  Was this answer useful?  Yes

bornToLose

  • Sep 22nd, 2007
 

Mode = mode + frequency[index] * (index+1)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions