繁体   English   中英

在头文件中包含头文件

[英]Including header file in header file

我在C ++中有以下代码:

#ifndef MYCLASS_H
#define MYCLASS_H

#include "gspace.h"

class myclass {
    public:

    void update(gspace **);
}

gspace是gspace.h中定义的另一个类。 但是编译器告诉我:

include/myclass.h error: ‘gspace’ has not been declared|

我的工作有什么问题吗?

编辑:

#ifndef GSPACE_H
#define GSPACE_H

#include <vector>
#include <iostream>
#include <math.h>

using namespace std;
class gspace
{
    public:
        gspace();

假设您甚至在gspace.h中声明了一个名为“ gspace”的类,那么我可能会想到两个可能的错误。

1)类gspace不在全局范围内,即可以在某些命名空间中。

2)请检查gspace中使用的标头域是否为“ MYCLASS_H”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM