C++ 此范围中未声明错误

C++ 此范围中未声明错误,c++,scope,C++,Scope,我有以下文件,我不明白为什么它不起作用,为什么我获得 “像素”未在此范围内声明 标题如下: #ifndef TABRESULTATS_H #define TABRESULTATS_H #include "Ligne.h" #include <iostream> #include <cmath> #include "Pixel.h" #include <vector> using namespace std; class Tableresultats {

我有以下文件,我不明白为什么它不起作用,为什么我获得

“像素”未在此范围内声明

标题如下:

#ifndef TABRESULTATS_H
#define TABRESULTATS_H
#include "Ligne.h"
#include <iostream>
#include <cmath>
#include "Pixel.h"
#include <vector>


using namespace std;

class Tableresultats
{

    public:
        Tableresultats(vector<Pixel> pixels);
        Tableresultats(vector<Pixel> pixels, int seuil);
        Tableresultats();
        virtual ~Tableresultats();
    protected:
    private:
        vector<int> m_debut;
        vector<int> m_duree;
        vector<int> m_valeurMax;
        int m_seuilGris;
};

#endif // TABRESULTATS_H
\ifndef TABRESULTATS\u H
#定义TABRESULTATS\u H
#包括“Ligne.h”
#包括
#包括
#包括“像素.h”
#包括
使用名称空间std;
类tableResults
{
公众:
TableResults(矢量像素);
TableResults(矢量像素,整数);
Tableresultats();
虚拟~Tableresultats();
受保护的:
私人:
向量m_;
向量m_duree;
向量m_valeurMax;
国际博物馆;
};
#endif//TABRESULTATS\u H
cpp:

#include "Tableresultats.h"
#include "Ligne.h"
#include <iostream>
#include <cmath>
#include "Pixel.h"
#include <vector>

using namespace std;
int vmaxTemp;
int dureeTemp;

Tableresultats::Tableresultats();
{
    m_seuilGris=180;   //valeur par defaut
    vector<int> debut();
    vector<int> duree();
    vector<int> vmax();
    //ctor
}

Tableresultats::Tablesreultats(vector<Pixel> pixels);
{
    // ...
}

Tableresultats::Tableresultats(vector<Pixel> pixels, int seuil);
{
    m_seuilGris=seuil;   //valeur par defaut
    // ...
}

Tableresultats::~Tableresultats()
{
}
#包括“Tableresultats.h”
#包括“Ligne.h”
#包括
#包括
#包括“像素.h”
#包括
使用名称空间std;
int vmaxTemp;
int dureeTemp;
Tableresultats::Tableresultats();
{
MySuulgRIS=180;/ Valeur-Par Dault
向量函数();
向量duree();
向量vmax();
//执行器
}
tableResults::tableReultats(向量像素);
{
// ...
}
Tableresultats::Tableresultats(矢量像素,整数);
{
MySuiGrigs= SuuIL;// Valeur-Par Dault
// ...
}
Tableresultats::~Tableresultats()
{
}
我的类像素:

#ifndef PIXEL_H
#define PIXEL_H
#include <iostream>
#include "Tableresultats.h"
using namespace std;
class Pixel
{
    public:
   ...

    protected:
    private:
        int m_couleurRGB[3]; //La couleur du pixel
        int m_niveauGris; //Niveau gris
        int m_posX; //reference X
        int m_posY; //reference Y
};

#endif // PIXEL_H
\ifndef像素
#定义像素
#包括
#包括“TableResults.h”
使用名称空间std;
类像素
{
公众:
...
受保护的:
私人:
int m_couleurRGB[3];//像素
int m_niveauGris;//Niveau gris
int m_posX;//引用X
int m_posY;//引用Y
};
#endif//PIXEL_H
我有其他文件,但我不明白我为什么会有这个问题:

像素未在此范围内声明,第16行TableResults.h标头


如果我声明了
#include
#include“Pixel.h”
,那么
Tableresultats.h
Pixel.h
之间存在循环依赖关系(它们相互包含)

您必须通过正确使用转发声明来解决这个问题

如果可能的话,也可以删除其中一个包含项(从您发布的
Pixel.h
中,它看起来不需要
Tableresultats.h
的包含项)