填空题
下列程序中的重载函数disp( )发生错误,错误原因是 【13】 。
# include<iostream, h>
class Sample
{
private:
int m;
static int sr;
public:
Sample(int a) {m=a; st+=a; }
static void disp(){cout<<m<<end1; }
static void disp(Sample input)
{
cout<<input. m<<end1;
}
};
int Sample: : st=2;
void main()
{
Sample Eirst(2), Second(4)
Sample: :disp( );
Sample: :disp (Second);
}
【参考答案】
在静态成员函数的实现中不能直接引用类中说明的非静态成员