tags:

views:

92

answers:

1

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;
}

Edit :

After making the change to printFn while running the program i get an error message " version `GLIBCXX_3.4.14' not found (required by ./a.out)". what does this indicate ?

+5  A: 

Wrong function name printEn <-> printFn.

Phong
Ahh!! Thanks.. that's all I can say..
Eternal Learner
Your welcome! `was not declared in this scope` means check namespace, include, name of the function/variable
Phong
Now while running it I get an error msg " version `GLIBCXX_3.4.14' not found (required by ./a.out)" This compiled fine though!!
Eternal Learner
@Eternal: That isn't directly related to your original question, which seems to be solved. Why not ask a new one about that specific problem?
Georg Fritzsche
@ Georg : Sure thanks.
Eternal Learner
@Eternal: ...and don't forget to accept correct answers.
Johnsyweb