嵌套名称空间中的转发声明 [英] Forward Declaration in a nested namespace

查看:104
本文介绍了嵌套名称空间中的转发声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在嵌套名称空间中的前向声明有问题.我在嵌套名称空间中为类或结构添加了前向声明,当我尝试在该名称空间的父级中使用它时,出现错误.我不知道该怎么办.

I'm having a problem with forward declarations in a nested namespace. I put a forward declaration for a class or struct in a nested namespace and when I try to use it in the parent of that namespace I get an error. I don't know what to do.

这是代码的样子:

#include "Data\Types.hpp"

namespace GameEngine
{
    class Console
    {
    public:
        class Renderer : public RenderComponent2D
        {
        public:
            Renderer(Console*, const GameEngine::DataProcessing::FontData*);
//...

并在Data \ Types.hpp中:

and in Data\Types.hpp:

namespace GameEngine
{
    namespace DataProcessing
    {
        struct FontData;
//...

MinGW给我的错误是:

and the error MinGW gives me is :

'FontData' in namespace 'GameEngine::DataProcessing' does not name a type

感谢您对此问题的任何帮助或建议.

I appreciate any help or suggestions with this problem.

推荐答案

可能是方法声明中的问题.您已经在GameEngine名称空间中:

May be problem in declaration of method. You are already inside GameEngine namespace:

namespace GameEngine
{
    class Console

但是在声明中,您也使用此命名空间:

But in declaration you use this namespace too :

 Renderer(Console*, const GameEngine::DataProcessing::FontData*);

不用GameEngine尝试一下:

Try it without GameEngine :

 Renderer(Console*, const DataProcessing::FontData*);

这篇关于嵌套名称空间中的转发声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆