假定有定义“intb[10];int*pb;”,则不正确的赋值语句为()。
第1题:
要使语句“p=new int[10][20]”正确,p应事先定义为
A: int*p
B: int**p
C: int*p[20]
D: int(*p)[20]
第2题:
若x是整型变量,pb是基本类型为整型的指针变量,则正确的赋值语句是 ( )
A.pb=&x;
B.pb=x;
C.* pb=& x;
D.* pb=* x;
第3题:
a. pb=b;
b. pb=&b[0];
c. pb=b+2;
d. pb=b[5];
第4题:
如下程序执行后的输出结果是【 】。
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;
}
第5题:
有以下程序
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;
}
运行后的打印结果是______。
第6题:
若x是整型变量,pb是基类型为整型的指针变量,则不正确的赋值表达式是()。
A、*pb=&x;
B、pb=&x
C、pb=x;
D、*pb=*x
第7题:
设有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]
第8题:
若x是整型变量,pb是基类型为整型的指针变量,则正确的赋值表达式是______。
A.pb=&x;
B.pb=x;
C.*pb=&x;
D.*pb=*x
第9题:
下面代码有何错误
void func1()
{
int *pa = NULL;
func2(pa);
delete pa;
}
void func2(int *pb)
{
pb = new int(5);
}
第10题:
下列程序中,正确的为______。
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); }