Hi I have a code which has structure explained below. This is not the actual code but I've tried to simulate the problem and it gives same error.
I've a file called classTest.cpp which contains:
#include<iostream>
#include "header.h"
using namespace std;
int main()
{
test f;
f.insert(10);
cout<<f.search(10)<<endl;
return 0;
}
header.h contains following code:
#include<unordered_set>
class test
{
public:
int apple;
unordered_set<int> set;
bool search(int a);
void insert(int a);
};
bool test::search(int a)
{
if(apple!=a)
return false;
return true;
/*
if(set.find(a) == set.end())
return false;
return true;*/
}
void test::insert(int a)
{
apple = a;
//set.insert(a);
}
When i compile classTest.cpp I get following error:
header.h:6:2: error: ‘unordered_set’ does not name a type
unordered_set<int> set;
But when I copy the header.h content and paste it into classTest.cpp it works fine. I am unable to understand the reason. Is there some basic concept that I'm missing?