我有兩個相互依賴的頭文件,但是一個頭文件無法看到另一個頭文件。無法從頭文件中看到全局變量文件
該頭文件聲明瞭地圖代理
#pragma once
#include <agents.h>
#include "Manage_A.h"
class M_Agent : public Concurrency::agent
{
public:
explicit M_Agent(Concurrency::ISource<int>& source, Concurrency::ITarget<wstring>& target) :
_source(source), _target(target)
{
}
protected:
void run() {
cout << "What Would You Like to Do?\n"
<< "1. Manage Agents\n"
<< "2. See Info From Agents\n"
<< "3. Alerts\n"
<< "4. Quit\n";
cin >> choice;
switch (choice)
{
//Manage Agents
case 1:
Manage_A();
run();
break;
//See Info from Agents
case 2:
cout << "INfo\n";
run();
break;
//Alerts
case 3:
cout << "Alerts\n";
run();
break;
//Quit
case 4:
exit(0);
break;
//Try again
default:
run();
break;
}
//done();
}
private:
int choice{ 0 };
Concurrency::ISource<int>& _source;
Concurrency::ITarget<wstring>& _target;
};
extern std::map<string, M_Agent*> Agents;
extern Concurrency::overwrite_buffer<int> buffer1;
extern Concurrency::unbounded_buffer<wstring> buffer2;
此標頭包含使用地圖
#pragma once
#include"M_Agent.h"
#include"F_Agent.h"
#include"Variables.h"
void Create_A()
{
system("cls");
string name{ "" };
int a_type{ 0 };
std::cout << "Please Name Agent\n";
std::cin >> name;
while (true)
{
std::cout << "What Type of Agent Would You like\n"
<< "1. Main Agent\n"
<< "2. File Agent\n"
<< std::endl;
std::cin >> a_type;
if (std::cin.good())
{
break;
}
else
{
system("cls");
std::cout << "Please enter correct choice" << std::endl;
}
std::cin.clear();
std::cin.ignore();
}
switch (a_type)
{
//Create Main Agent
case 1:
Agents.insert(std::make_pair(name, new M_Agent(buffer1, buffer2)));
system("cls");
break;
//Create File Agent
case 2:
F_Agents.insert(std::make_pair(name, new File_Agent(buffer1, buffer2)));
system("cls");
break;
}
return;
}
的問題是,所述第二頭文件說代理是一個未識別的識別符的功能。
數據不足...此程序員現在將退出。 – user4581301