C++ c++;叠瓦类中友元函数的前向声明

C++ c++;叠瓦类中友元函数的前向声明,c++,friend,forward-declaration,C++,Friend,Forward Declaration,我试图使用类描述符定义类提取的友元的函数成员,但编译时出现以下错误: *descripters.h:24:57:错误:不完整类型“类提取”的使用无效 void Extraction::globalSet(描述文档); descripters.h:19:7:错误:“类提取”的前向声明 类别抽取* 《守则》规定: //in Extraction.h #include "Descripteurs.h" class Extraction { public: Extraction(Descript

我试图使用类描述符定义类提取的友元的函数成员,但编译时出现以下错误:

*descripters.h:24:57:错误:不完整类型“类提取”的使用无效

void Extraction::globalSet(描述文档); descripters.h:19:7:错误:“类提取”的前向声明 类别抽取*

《守则》规定:

//in Extraction.h
#include "Descripteurs.h"
class Extraction {
public:
    Extraction(Descripteurs document);
    void globalSet(Descripteurs document);
protected:
    int m_value;
}

// in Extraction.cpp    
#include "Extraction.h"
Extraction::Extraction(Descripteurs document){
    this->globalSet(document);
}
void Extraction::globalSet(Descripteurs document){
    this->m_value = document.m_nbMot;   //this is why I need a friend function
    cout << this->m_value << endl;
}

//in Descripteur.h
class Extraction; //forward declaration, is there a problem with this ?
class Descripteurs {
public:
    friend void Extraction::globalSet(Descripteurs document);
protected:
    int m_value;
};
//在Extraction.h中
#包括“描述符.h”
类抽取{
公众:
摘录(描述文件);
void globalSet(说明文件);
受保护的:
int m_值;
}
//在Extraction.cpp中
#包括“Extraction.h”
提取::提取(描述符文档){
此->全局集(文档);
}
void Extraction::globalSet(描述符文档){
this->m_value=document.m_nbMot;//这就是为什么我需要一个friend函数

cout m_value不幸的是,您不能将前向声明类的成员函数声明为
friend
。请参阅以了解可能的解决方法。

我将其理解为“醉醺醺的类”。感谢您提供的链接,这正是我未成功查找的链接!我将研究这些解决方案,以尝试理解密钥t至少你给了我一个很好的提示,再次感谢。我很高兴。你能给我的最好的感谢就是点击旁边的绿色复选标记来“接受”这个答案。(作为提问者,你决定哪个回答应该被标记为“正确”。)