0

Why is this async wrong? The code works if the async is outside of the class but I need in there.

I am trying to pass my pointer list as reference to this class's function and there make the multithreading but it doesn't seem to work there...

#include<iostream>
#include<vector>
#include<future>
using namespace std;

class objectClass {

};

class someClass {
public:
    vector<future<void>> futures;

    void someFunction(objectClass* object) { }

    void someFunctionMAIN(vector<objectClass*>& objects) {
        for (auto obj : objects) {
            futures.push_back(async(launch::async, someFunction, obj));
        }
    }
};


void main() {
    vector<objectClass*> objects;

    objects.push_back(new objectClass);

    someClass class1;
    class1.someFunctionMAIN(objects);
}

0 Answers0