设有以下类的定义:
class Ex
{ int x;
public:
void setx(int t=0);
};
若在类外定义成员函数setx( ),以下定义形式中正确的是
A.void setx(int t){…}
B.void Ex::setx(int t){…}
C.Ex::void setx(int t){…}
D.void Ex::setx( ){…}
第1题:
设有以下函数:
voidfun(intn,char}s){……}
则下面对函数指针的定义和赋值均正确的是( )。
A.void(*pf)(int,char);pf=&fun;
B.void+pf( );pf=fun;
C.void*pf( );*pf=fun;
D.void(*pf)(int,char*);pf=fun;
第2题:
第3题:
已知一个类Sample,()是定义指向类Sample成员函数的指针,假设类有三个公有成员: void f1(int)、void f2(int)和int a。
A.Sample *p
B.int Sample::*pc=&Sample::a
C.void (Sample:: *pa)(int)
D.Sample *a[10]
第4题:
有以下程序: #include <iostream> using namespace std; class sample { private: int x; public: void setx(int i) { x=i; } int putx () { return x; } }; int main ( ) { sample *p; sample A[3]; A[0] .setx(5); A[1] .setx (6); A[2] .setx(7); for (int j=0;j<3;j++) { p=&A[j]; cout<<p->putx () <<", "; } cout<<end1; return 0; } 执行后执行结果是( )。
A.5,6,7,
B.5,5,5,
C.6,6,6,
D.7,7,7,
第5题: