问答题

下面程序用于输出最小值,有一处错误。
#include < iostream.h >
class Test
{ int a, b;
int getmin()
{return (a<b a:b);}
public:
int c;
void setValue( int x1, int x2, int x3 )
{ a =x1; b =x2; c =x3;}
int GetMin();
};
int Test::GetMin()
{ int d = getmin ();
return (d=d<c d:c);
}
void main()
{ Test t1;
t1.setValue(34,6,2);
cout << t1.getmin () << endl;
}

【参考答案】

cout<<t1.getmin()<<endl; 成员函数getmin()采用默认的访问权限即私有的,在外部无法访问。应......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)