0
最近我問了關於層級頭文件here的問題。我得到了答案,並將其標記爲解決方案。但過了一段時間後,我對這個主題還有其他疑問。那嵌套類型呢?我想要在類型層次結構的頭文件中顯示嵌套類型。例如(請閱讀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
沒有嵌套類型,我的類型層次結構將不會完整。我怎麼解決這個問題?
P.S.我可以在註釋中寫入關於嵌套類型的信息。我認爲這是單一的解決方案。我對嗎?
謝謝。