假定有定义“intb[10];int*pb;”,则不正确的赋值语句为()。
第1题:
若x是整型变量,pb是基本类型为整型的指针变量,则正确的赋值语句是 ( )
A.pb=&x;
B.pb=x;
C.* pb=& x;
D.* pb=* x;
第2题:
有以下程序
include <iostream>
using namespace std;
class Base
{
int a;
public:
Base(int x){ a=x; }
void show(){ cout<<a; }
class Derived : public Base
{
int b;
public:
Derived(int i) :Base(i+1),b(i){}
void show() { cout<<b;
};
int main ()
{
Base b(5),*pb;
Derived d(1);
pb=&d;
pb->show ();
return 0;
}
运行后的打印结果是______。
第3题:
如下程序执行后的输出结果是【 】。
include <iostream>
using namespace std;
class Base
{
public:
Base(int x,int y)
{
a=x;
b=y;
}
void Show()
{
cout<<"Base: "<<a<< ',' <<b<<" ";
}
private:
int a,b;
};
class Derived : public Base
{
public:
Derived(int x, int y, int z) : Base(x,y),c(z) { }
void Show()
{
cout<<"Derived:"<<c<<end1;
}
private:
int c;
};
int main()
{
Base b(100,100),*pb;
Derived d(10,20,30);
pb=&b;
pb->Show();
pb=&d;
pb->Show();
return 0;
}
第4题:
为使程序的输出结果为: Base:: fun 那么应在下列程序画线处填入的正确语句是( )。 #include <iostream> using namespace std; class Base { public: void fun () { cout<<"Base: :fun"<<end1; } }; class Derived : public Base { public: void fun ( ) { cout<<"Derived: :fun"<<end1; } }; int main ( ) { Base a,*pb; Derived b; _________; pb->fun(); //调用基类的成员函数 fun() return 0 ; }
A.pb=&a
B.pb=b
C.pb=&b
D.pb=&Base
第5题:
有以下程序: #inClUde <iostream> using namespace std; Class Base { public: Base(int x) { a=x; } void show() { cout<<a; } private: int a; }; class Derived : public Base { public: Derived(int i) :Base(i+1),b(i){} void Show() { cout<<b; } private: int b; }; int main() { Base b(5),*pb; Derived d(1); pb=&d; pb->show(); return 0; } 运行后的输出结果是( )。
A.1
B.5
C.2
D.0
第6题:
假定有语句为“int b[10]; int *pb;”,则下面不正确的赋值语句为()。
Apb=b;
Bpb=&b[0];
Cpb=b+2;
Dpb=b[5];
第7题:
假定有定义“intb[10];int*pb;”,则不正确的赋值语句为()。
第8题:
要使语句“p=newint[10][20];”正确,p应事先定义为()。
第9题:
假定有定义“intb[10];int*pb;”,则不正确的赋值语句为()。
第10题:
pb=b;
pb=&b[0];
pb=newint;
pb=b[5];
第11题:
&pb=a;
pb=pa;
pb=&pa;
?pb=?pa;
第12题:
*(pb+l)=24
*(b+l)=24
*++b=24
*++pb=24
第13题:
设有C语言变量说明“static int a[][2]={{1,2),(3,4}};int *pa,(*pb)[2];”,则执行语句“pa=pb=&a[0][0];”后,(*(pa+1))的值为(31)。
A.2
B.3
C.&a[0][1]
D.&a[1][0]
第14题:
下面代码有何错误
void func1()
{
int *pa = NULL;
func2(pa);
delete pa;
}
void func2(int *pb)
{
pb = new int(5);
}
第15题:
下列程序中,正确的为______。
A.main() { int *pb=&b; float 1>=15.25; print f("%d\n" ,*pb); }
B.amin() { int a,*pa; a=10; *pa=a; prinffC%d",*pa); }
C.main() { char s[20]; char *ps=&s; scanf("%s",*p); printf("%s",*p); }
D.main() { char str[10]; int *ps=str[0]; str="abcdefg"; printf("%s",*p); }
第16题:
A、p
B、*p
C、*&x
D、*p=x
E、x=*p
第17题:
A.int*p
B.int**p
C.int*p[20]
D.int(*p)[20]
第18题:
有以下变量说明,下面正确的语句是() int a=10,b; int &pa=a,&pb=b;
第19题:
假定有定义“intb[10];int*pb;”,则不正确的赋值语句为()。
第20题:
假定变量b和pb定义为“intb[10],*pb=b;”,要将24赋值给b[l]元素中,不正确的赋值语句是()。
第21题:
pb=b
pb=&b[0]
pb=newint
pb=b[5]
第22题:
pb=b;
pb=&b[0];
pb=b+2;
pb=b[5];
第23题:
pb=b;
pb=&b[0];
pb=new int;
pb=b[5];