/**********************************************
Threads implementation
**********************************************/
#include<windows.h>
#include<iostream>
usingnamespace std;
struct DATA{
int age;
string fname,lname;
};
void function(DATA*pdata){
cout<<"The pointer to struct DATA :"<<pdata<<endl;
cout<<"Age :"<<pdata->age <<"Years."<<endl;
cout<<"First Name: "<<pdata->fname <<endl;
cout<<"Last Name :"<<pdata->lname <<endl;
Sleep(2000);
}
int main(){
DATA idata;
idata.age =10;
idata.fname ="Charlie";
idata.lname ="Junior";
DWORD tID;
HANDLE threadhandle=CreateThread(0,0,(LPTHREAD_START_ROUTINE)function,&idata,0,&tID);
if(INVALID_HANDLE_VALUE==threadhandle){
cout<<"Error code :"<<GetLastError()<<endl;
}
/*wait for the thread to finish*/
while(WaitForSingleObject(threadhandle,3000)==WAIT_TIMEOUT){
cout<<"Thread Execution Finished...."<<endl;
}
return 0;
}
The error are :
C:\programs\struct\struct.cpp(11) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversi
on)
C:\programs\struct\struct.cpp(12) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversi
on)
Can somebody help with this...Thanks