展开全部
可以,给你个例子看看,问技术问题都不给分,太扣了
#include <iostream>
class CTest
{
public:
/// 指向了成员函数.
bool (CTest::* m_pFun)( int );
/// 指向了成员变量.
int (CTest::* m_pVal);
public:
CTest()
{
/// 赋值,指向成员指针.
m_pFun = &CTest::test;
/// 赋值,指向成员变量.
m_pVal = &CTest::m_nVal;
}
bool test( int nParam )
{
std::wcout << nParam << std::endl;
return TRUE;
}
int m_nVal;
};
void main()
{
CTest val;
/// 调用成员函数.
(val.*(val.m_pFun))(999);
/// 调用成员变量.
val.*(val.m_pVal) = 100;
std::wcout << val.m_nVal << std::endl;
}
#include <iostream>
class CTest
{
public:
/// 指向了成员函数.
bool (CTest::* m_pFun)( int );
/// 指向了成员变量.
int (CTest::* m_pVal);
public:
CTest()
{
/// 赋值,指向成员指针.
m_pFun = &CTest::test;
/// 赋值,指向成员变量.
m_pVal = &CTest::m_nVal;
}
bool test( int nParam )
{
std::wcout << nParam << std::endl;
return TRUE;
}
int m_nVal;
};
void main()
{
CTest val;
/// 调用成员函数.
(val.*(val.m_pFun))(999);
/// 调用成员变量.
val.*(val.m_pVal) = 100;
std::wcout << val.m_nVal << std::endl;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询