Reputation: 81
Ok I know there are millions of variations of this particular problem, and I have tried (desperately) to go through them all and see if they apply, to no avail.
Currently I'm trying to declare a deque in a header file, and the damn thing wont let me due to the error mentioned. The same thing happens to me in a lot of my projects, and I think its just something basic I'm lacking in my knowledge of c++ class syntax.
main.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;
}
I havn't shown the rest of the file for clarities sake, and im pretty confident it isnt the problem. The error appears in Card.h:
Card.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
card.cpp
#include "Card.h"
Card::Card()
{
//ctor
}
Card::~Card()
{
//dtor
}
To anyone who can help - thanks in advance! Ill be very happy when I understand whats wrong here!!!
Upvotes: 2
Views: 1070
Reputation: 158619
You need to specify the namespace
in card.h
when you declare the param_name_deque
and param_value_deque
:
std::deque<std::string> param_name_deque;
std::deque<double> param_value_deque;
and include the proper headers:
#include <string>
#include <deque>
I would avoid using namespace std, it may seem convenient but it will eventually cause you problems.
Upvotes: 3
Reputation: 23664
You have to include both std::deque and std::string in your header file card.h
#include <string>
#include <deque>
Meanwhile,
deque<string> param_name_deque;
deque<double> param_value_deque;
should be
std::deque<std::string> param_name_deque;
std::deque<double> param_value_deque;
Upvotes: 6