求高手解释一下这段程序#include class Test {int x,y; public: Test(int i,int j=0) {x=i;y=j;} int get(int i,int j) {return i+j;} }; void main() {Test t1(2),t2(4,6); int (Test::*p)(int,int=10); p=Test::get; cout
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 06:57:01
求高手解释一下这段程序#include class Test {int x,y; public: Test(int i,int j=0) {x=i;y=j;} int get(int i,int j) {return i+j;} }; void main() {Test t1(2),t2(4,6); int (Test::*p)(int,int=10); p=Test::get; cout
求高手解释一下这段程序
#include
class Test
{int x,y;
public:
Test(int i,int j=0)
{x=i;y=j;}
int get(int i,int j)
{return i+j;}
};
void main()
{Test t1(2),t2(4,6);
int (Test::*p)(int,int=10);
p=Test::get;
cout
求高手解释一下这段程序#include class Test {int x,y; public: Test(int i,int j=0) {x=i;y=j;} int get(int i,int j) {return i+j;} }; void main() {Test t1(2),t2(4,6); int (Test::*p)(int,int=10); p=Test::get; cout
这代码我感觉完全是为了考人准备的,要不谁去写这东西,类对象也有,成员函数也有,费要搞个成员函数指针,不麻烦么,
int (Test::*p)(int,int=10);
p=Test::get; 这2句就是错的,定义成员函数指针要求形参返回类型完全一致,怎么还能设置个默认值呢.
---------------------------------------------------------
#include
using namespace std;
class Test
{int x,y;
public:
Test(int i,int j=0)
{x=i;y=j;}
int get(int i,int j)
{return i+j;}
};
int main()
{Test t1(2),t2(4,6);
int (Test::*p)(int,int);
p=&Test::get;
cout