為了獲取Class的private成員的數(shù)據(jù)---int* flag = (int*)(ctest);
#include<iostream>
class CTest
{
private:
int m_y;
public:
CTest(int value){m_y = value;}
~CTest(){}
void
getValue(){std::cout<<"m_y is:
"<<m_y<<std::endl;}
};
void getClassValue(CTest* ctest)
{
//for(int* flag =
(int*)(ctest);*flag!=NULL;flag++)
int* flag = (int*)(ctest);
std::cout<<*flag<<std::endl;
//flag++;
std::cout<<*(++flag)<<std::endl;
//這里同時(shí)也反映出++i和i++的區(qū)別
std::cout<<*flag<<std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
CTest* test=new CTest(2);
test->getValue();
getClassValue(test);
delete test;
system("pause");
return 0;
}
posted on 2009-08-22 18:52
閆軍yy 閱讀(419)
評(píng)論(0) 編輯 收藏 引用 所屬分類:
c++/c