Problem with futures in c++0x .
- by Eternal Learner
Hi, I have written a small program , to understand how futures work in c++0x. while running the code I get an error like " error: 'printEn' was not declared in this scope". I am unable to understand what the problem is..Kindly point out what I am doing wrong here and if possible write the correct code for the same..
#include <future>
#include <iostream>
using namespace std;
int printFn()
{
for(int i = 0; i < 100; i++)
{
cout << "thread " << i << endl;
}
return 1;
}
int main()
{
future<int> the_answer2=async(printEn);
future<int> the_answer1=async(printEn);
return 0;
}