jeudi 20 septembre 2018

C++ Calling a function from another class using async

I have two classes A and B in two different header files. Say, A.h

class A {
public:
int foo(int a); // which is defined in A.cpp file
};

I have other class in B.h

#include "A.h"
#include <future>
class B{
void bar() {
 future<int> f = (std::launch::async,&A::foo,this,25); // This line gives me error
}
};

Error: 'future<_Res &>' is not compatible with class 'future'

How do I fix this issue?

Aucun commentaire:

Enregistrer un commentaire