#include <iostream>
using namespace std;
class A
{
int i;
public:
A()
{
i = 11;
}
int geti(void)
{
return i;
}
};
int fun(void)
{
return 1;
}
int main()
{
A *pA = new A[4];
for (int i = 0; i < 4; i ++)
{
cout << pA[i].geti() << endl;
cout << pA+i << endl;
cout << pA[i].geti << endl; //编译器内部错误
cout << fun << endl; //没有错误
}
delete [] pA;
cout << pA[0].geti() << endl;
cout << pA << endl;
return 0;
}
错误内容如下:
--------------------Configuration: Test - Win32 Debug--------------------
Compiling...
main.cpp
D:\MyVSProjects\VC\Test\main.cpp(34) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file msc1.cpp, line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.
Test.exe - 1 error(s), 0 warning(s)
这里不对啊!
cout << pA[i].geti << endl; //编译器内部错误
该:
cout << pA[i].geti() << endl;
再你标示“//编译器内部错误”的那一行,居然是cout << pA[i].geti << endl;
你的geti是一个函数,必须用geti()调用。我已经调试通过,但结果对不对就你自己看了。
cout << pA[i].geti << endl; ????
try
cout << pA[i].geti() << endl;
那你用
cout<<A::geti<<endl
试一试
如此看来
成员函数的地址是隐藏起来的
这个用法没有见过,用 .*或者->*试试
我运行的时候没有问题啊???
我用的编译器是devcpp
输出结果如下:
11
0x473880
11
1
11
0x473884
11
1
11
0x473888
11
1
11
0x4738c
11
1
0
0x473880
cout << &A::geti << endl;