C++ 静态成员函数调用非静态成员函数方法
来源:互联网 发布:淘宝模特兼职价格 编辑:程序博客网 时间:2024/06/05 04:07
#include <stdio.h>#include <windows.h>class Class;typedef struct {Class *pClass;int x;int y;}ParaNode;class Class{public:int i;void Seti(int index){i=index;}bool SaneCommandSASTest(int x,int y){ printf("sum: x+y = %d\n",x+y); srand((unsigned)time(NULL)); int rate=rand()%5; if(rate<2) { while(1); } else if (rate == 2) { return false; } else { return true; } }static DWORD WINAPI SendEraseCommandThread( LPVOID lpParameter );int ExecuteCommand(int x,int y);int Print();private: bool m_sendCommandResult;bool m_getProcessResult;int m_processResult;};DWORD WINAPI Class::SendEraseCommandThread( LPVOID lpParameter ){ParaNode *paranode = (ParaNode*)lpParameter;printf("Enter into ThreadProc\n");bool m_sendCommandResult;bool m_getProcessResult;int m_processResult;paranode->pClass->m_sendCommandResult=false;paranode->pClass->m_sendCommandResult=paranode->pClass->SaneCommandSASTest(paranode->x,paranode->y);return 0;}int Class::Print(){printf(" --------Print Test -----------\n");return 0;}int Class::ExecuteCommand(int x,int y){ HANDLE hHandle;ParaNode node;node.pClass = this;node.x=x;node.y=y;hHandle=CreateThread(NULL, 0, &Class::SendEraseCommandThread, (LPVOID)&node, 0, 0);if(WaitForSingleObject(hHandle,1000) == WAIT_TIMEOUT){ //printf("WaitForSingleObject(hHandle,10000) == WAIT_TIMEOUT\n"); printf("ExecuteCommand SendEraseCommandThread TimeOut failed\n");}else{ if(m_sendCommandResult) { printf("ExecuteCommand SendEraseCommandThread successfully\n"); } else { printf("ExecuteCommand SendEraseCommandThread failed\n"); }}return 0;}int main(){srand((unsigned)time(NULL));Class c1;c1.Seti(10);for (int i = 0;i <1000;i++){ c1.ExecuteCommand(rand()%500,rand()%500);}//c1.ExecuteCommand(20,33);return 0;}
0 0
- C++ 静态成员函数调用非静态成员函数方法
- 静态成员函数调用非静态成员
- 静态成员函数调用非静态成员变量
- 静态成员函数调用非静态成员变量
- 用静态成员函数调用非静态成员变量
- 静态成员函数调用非静态成员变量
- 静态成员函数调用非静态成员变量
- 静态成员函数调用非静态成员变量
- 静态成员函数调用非静态成员变量
- 用静态成员函数调用非静态成员变量
- 静态成员函数调用非静态成员变量
- 静态成员函数调用非静态成员变量-p…
- 静态成员函数调用非静态成员变量-p…
- 静态成员函数如何调用非静态成员变量
- 静态成员函数调用非静态成员变量(转)
- C++静态成员函数不能调用非静态成员变量
- 静态成员函数调用非静态成员变量
- 静态成员函数引用非静态成员
- log4net - Write log to WinForm TextBox
- Machine Learning Basis
- C++打印位数为n的所有数
- ORACLE EBS架构与管理基础(12.1.3)学习总结
- libevent源码之TAILQ详解
- C++ 静态成员函数调用非静态成员函数方法
- 列表(1)
- Fabric不能启动后台进程问题
- [LeetCode] Invert Binary Tree
- Android 之 网络访问服务器,解析JSON数据(返回无乱码)
- HTTP协议学习笔记
- 【机房重构】—上机&订餐
- log4net 使用方法
- C++二插树和值与子树求解