0

i have just started studying concurrency in c++11 std But i can't get this program to compile

 #include<future>
 #include<iostream>


 int func1(const int &i)
 {
   return i*i;  

 }


 int func2(const int &i)
 {


      return 2*i;
 }

 int main()
 {


    auto result1(std::async(func1,2));//error in this line says invalid use of incomplete type 'class std::future<int>'
    int result2 = func2(4);
    int result = result1.get() + result2;
    std::cout<<"\t result"<<result;
    return 0;
 }

Can somebody explain the error i have also tried using std::future instead of auto but it does not work.

rahul tyagi
  • 643
  • 1
  • 7
  • 20

0 Answers0