Hi,
please check my code..
I want to pass a class object into a method of other class through a thread call, I tried but got the error can any one help me on this.please.
struct sample{
int status;
std::vector <std::string> a_row;
size_t column_count;
std::vector <std::string> column;
};
class sess {
private:
public:
int a;
sess(int);
sess();
};
class Gen {
private:
static Gen* gen_obj;
public:
static bool Gen_InstanceFlag;
static Gen* GetInstance();
sample addition(sess);
};
/* End of Header File */
/* Beginning of cpp File */
#include"Class_thread_mixing.h"
bool Gen::Gen_InstanceFlag=false;
Gen* Gen::GetInstance(){
if(!Gen::Gen_InstanceFlag){
Gen::gen_obj = new Gen();
Gen::Gen_InstanceFlag= true;
return gen_obj;
}
else {
return gen_obj;
}
}
sample addition(sess ses_obj){
sample sam;
sam.a_row.push_back("success");
sam.column.push_back("result");
sam.column_count=1;
sam.status=ses_obj.a;
return sam;
}
int main(int argc, char* argv[])
{
HANDLE myhandleA,myhandleB,myhandleC;
Gen* gen=Gen::GetInstance();
sess ses_obj(10);
myhandleA=(HANDLE)_beginthreadex(0, 0, gen->addition(ses_obj),(void*)0, 0, 0);
WaitForSingleObject(myhandleA, INFINITE);
CloseHandle(myhandleA);
getchar();
return 0;
}
This is my code and I am getting an error like "error C2665: '_beginthreadex' : none of the 2 overloads could convert all the argument types"
Can any one suggest me who can I pass the object of sess to a funtion in a thread call and how can I get the results from the thread.
Last edited on
Last edited on
You can't do that. Remember a thread is a separate/parallel unit of execution.
I think you need to pass that session thing as a parameter to something. But I'm not clear on what you're doing.
But first, can you format your code. It's really difficult to read unformatted code.