好吧,我知道这个特定问题有数百万种变体,我已经(拼命地)尝试遍历所有变体,看看它们是否适用,但无济于事。
目前我正在尝试在头文件中声明一个双端队列,由于提到的错误,该死的东西不会让我这样做。在我的很多项目中,同样的事情发生在我身上,我认为这只是我对 C++ 类语法的了解所缺乏的一些基本知识。
主要.cpp
#include <iostream>
#include <fstream>
#include <string>
#include <deque>
#include "Card.h"
#include "random.h"
using namespace std;
void createloop();
int get_option();
deque <Card> make_new_deck();
deque <Card> load_new_deck();
int main()
{
createloop();
return 0;
}
为了清楚起见,我没有显示文件的其余部分,我非常有信心这不是问题所在。错误出现在Card.h中:
卡片.h
#ifndef CARD_H
#define CARD_H
class Card
{
public:
Card();
deque<string> param_name_deque;
deque<double> param_value_deque;
virtual ~Card();
protected:
private:
};
#endif // CARD_H
卡片.cpp
#include "Card.h"
Card::Card()
{
//ctor
}
Card::~Card()
{
//dtor
}
对于任何可以提供帮助的人 - 提前致谢!当我明白这里出了什么问题时我会很高兴!!!
最佳答案
你必须在头文件 card.h
中包含 std::deque 和 std::string
#include <string>
#include <deque>
同时,
deque<string> param_name_deque;
deque<double> param_value_deque;
应该是
std::deque<std::string> param_name_deque;
std::deque<double> param_value_deque;
关于c++ - ISO 禁止声明没有类型的 "identifier"。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15915476/