Created
July 5, 2019 17:51
-
-
Save rpapallas/bec9aeb75ee0cbe60e970e66498da1bd to your computer and use it in GitHub Desktop.
C++ thread of a class overloaded method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass { | |
. | |
. | |
bool desiredOverloadedMethod() { | |
return true; | |
} | |
bool desiredOverloadedMethod(int a) { | |
if(a == 1) | |
return false; | |
return true; | |
} | |
}; | |
MyClass objectInstance(someArgument); | |
// This points to the first method (desiredOverloadedMethod) without arguments. | |
bool (MyClass::*myFunc)() = &MyClass::desiredOverloadedMethod; | |
thread t1(myFunc, std::ref(objectInstance)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment