How to declare nested types in a hierarchy header file?

I recently asked a question about the hierarchy header file writing here . I got a response and marked it as a solution. But after a while I have an additional question on this topic. What about nested types? I want nested types to also appear in my type hierarchy header file. For example (read TODO, please):

/* hierarchy.h Β© Andrey Bushman, 12 July 2013 This file contains the full hierarchy of this application types. This file must be included into the each header file of this application. */ //----------------------------------------------------------------------------- #ifndef BUSH_HIERARCHY_H #define BUSH_HIERARCHY_H #include <iostream> #include <string> #include <exception> //***************************************************************************** namespace Bushman{ //***************************************************************************** namespace Common{ // run-time checked narrowing cast (type conversion) template <class R, class A> inline R narrow_cast(const A& a); // Throw the exception with the msg message. void error(const std::string& msg); } //***************************************************************************** namespace CAD_Calligraphy{ class Shp_istream; // Stream for SHP file reading. class Shp_ostream; // Stream for SHP file writing. class Token; // Token of the SHP file. // TODO: The next both rows is not allowed (for nested types): enum Token::Type; // Type of Token item. class Token::Some_inner_class; // Class for internal use in the Token. } //***************************************************************************** } #endif 

Without nested types, the type hierarchy will not end. How can I solve this problem?

PS I can write in the comments information about nested types. I think this is the only solution. I'm right?

Thanks.

0
source share
1 answer

You cannot forward nested types. As a workaround, you can move them to a separate namespace, but that’s all.

0
source

Source: https://habr.com/ru/post/1491080/


All Articles