How can I declare the nested types in my hierarchy header file?

我怕爱的太早我们不能终老 提交于 2019-12-11 14:58:34

问题


Recently I asked the question about the hierarchy header file writing here. I got the answer, and marked it as the solution. But after a while I have additional question on this topic. What about the nested types? I want that at my header file of the types hierarchy there were also nested types displayed. For example (read the TODO, please):

/*
hierarchy.h
© Andrey Bushman, 12 July 2013
This file contains the full hierarchy of this application's 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 the nested types my types hierarchy will not be complete. How can I solve this problem?

P.S. I can write in the comments an info about the nested types. I think this is single solution. Am I right?

Thank you.


回答1:


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



来源:https://stackoverflow.com/questions/17613383/how-can-i-declare-the-nested-types-in-my-hierarchy-header-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!