若有定义:int x=0, *p=&x;, 则语句 printf("%d\n",*p);的输出结果是()。A.随机值B.0C.x 的地
若有定义:int x=0, *p=&x;, 则语句 printf("%d\n",*p);的输出结果是()。
A.随机值
B.0
C.x 的地址
D.p的地址
若有定义:int x=0, *p=&x;, 则语句 printf("%d\n",*p);的输出结果是()。
A.随机值
B.0
C.x 的地址
D.p的地址
若有以下程序:
#include using namespace std ; class Point { int x, y; public :
Point () { x = 0; y = 0; } void SetPoint (int x1, int y1) { x = x1; y = y1; } void DisPoint () { cout << "x=" << x << "," << "y=" << y << endl ; } }; int main() { Point * p = new Point ; p-> SetPoint (5, 12); p-> DisPoint (); delete p; return 0; } 上面程序的输出结果为:
若有以下程序:#include<iostream>using namespace std;class A {private: int x;public: int z; void setx(int i) { x=i; } int getx () { return x; }}:class B : public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a) ; z=b; m=c; } void display{) { cout<<getx ()<<", "<<z<<", "<<m<<end1; }};int main(){ B obj; obj. setvalue(2,3,4); obj.display(); return 0;} 程序运行以后的输出结果是
A.产生语法错误
B.2,3,4
C.2,2,2
D.4,3,2
若有以下程序: #include 〈iostream〉 using namespace std; class A { private: int x; public: int z; void setx(int i) { x=i; } int getx () { return x; } }; class B : public A { private: int m; public: int p; void setvalue(int a,int b, int C) { setx (A) ; z=b; m=c; } void display() { cout〈〈getx()〈〈","〈〈z〈〈","〈〈m〈〈end1; } }; int main () { B obj; obj.setvalue(2,3,4); obj.display(); return 0; } 程序运行以后的输出结果是()。
A.产生语法错误
B.2,3,4
C.2,2,2
D.4,3,2
若有以下程序:#include <iostream>using namespace std;class A{private: int x;public: int z; void setx(int i) { x=i; } int getx() { return x; }};class B: public A{private: int m;public: int p; void setvalue(int a, int b, int c) { setx(a); z=b; m=c; } void display() { cout<<getx()<<","<<z<<","<<m<<end1; }};int main(){ B obj; obj.setvalue(2,3,4); obj.display(); return 0;程序运行以后的输出结果是()
A.产生语法错误
B.2,3,4
C.2,2,2
D.4,3,2
若有以下程序: #include <iostream> using namespace std; class Base { int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx () { return x; } }; class Inherit : private Base { private: int m; public: int p; void setvalue(int a,int b,int c, int d) { setx(a) ; y=b; z=c; m=d; } void display() { cout<<getx ()<<", "<<y<<", "<<z<<", "<<m<<end1; } }; int main() { Inherit A; A.setvalue(1,2,3,4); A.display(); return 0; } 程序运行后的输出结果是()。
A.1,2,3,4
B.产生语法错误
C.4,3,2,1
D.2,3,4,5
以下程序的定义语句中,x[1]的初值是 [9] ,程序运行后输出的内容是 [10] 。
include <stdio.h>
main()
{ int x[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},*p[4],i;
for(i=0;i<4;i++)
{ p[i]=&x[2*i+1];
printf("%d",p[i][0]);
}
printf("\n");
}
以下程序段的定义语句中, x[1] 的初值是 【 9 】 ,程序运行后输出的内容是 【 10 】 。
#include <stdio.h>
main()
{ int x[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},*p[4],i;
for(i=0;i<4;i++)
{ p[i]=&x[2*i+1];
printf("%d",p[i][0]);
}
printf("\n");
}
A.for(i=0;i<6;i++) printf("%2d",*(p++));
B.for(i=0;i<6;i++) printf("%2d",*(p+i));
C.for(i=0;i<6;i++) printf("%2d",*p++);
D.for(i=0;i<6;i++) printf("%2d",(*p)++);