如何在我的层次结构头文件中声明嵌套类型? [英] How can I declare the nested types in my hierarchy header file?
问题描述
最近我问了关于层次结构头文件的问题。此处。我得到的答案,并标记为解决方案。但过了一会儿我还有一个关于这个话题的问题。嵌套类型呢?我想要在我的类型层次结构的头文件也有嵌套类型显示。例如(请读取TODO):
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?
谢谢。
推荐答案
嵌套类型。作为解决方法,您可以将它们移动到单独的命名空间,但这是所有。
You cannot forward nested types. As a workaround you can move them to separate namespace, but that is all.
这篇关于如何在我的层次结构头文件中声明嵌套类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!