0

最近我问了关于写在这里的层次头文件的问题。我得到了答案,并将其标记为解决方案。但过了一会儿,我对这个话题还有其他问题。嵌套类型呢?我希望在类型层次结构的头文件中也显示嵌套类型。例如(请阅读 TODO):

/*
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

如果没有嵌套类型,我的类型层次结构将不完整。我怎么解决这个问题?

PS 我可以在评论中写下有关嵌套类型的信息。我认为这是单一的解决方案。我对吗?

谢谢你。

4

1 回答 1

0

您不能转发嵌套类型。作为一种解决方法,您可以将它们移动到单独的命名空间,但仅此而已。

于 2013-07-12T11:23:49.673 回答