单项选择题
若有如下程序:
#include <iostream>
using namespace std;
int main()
char *p="abcdefgh",*r;
long *q;
q=(long *)p;
q++;
r=(char *)q;
cout<<r<<end1;
return 0;
上述程序的输出结果是( )。
A.abcdefgh
B.0
C.abcd
D.efgh
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
若有以下程序: #include <iostream> using namespace std; class Base private: int a,b; public: Base(int x, int y) a=x; b=y; void disp () cout<<a<< <<b<<end1; ; class Derived : public Base private: int c; int d; public: Derived(int x,int y, int z,int m) :Base(x,y) c=z; d=m; void disp () cout<<c<< <<d<<end1; ; int main() Base b(5,5),*pb; Derived obj(1,2,3,4); pb=&obj; pb->disp(); return 0; 执行程序后的输出结果是( )。
A.1,2
B.3,4
C.2,3
D.5,5
点击查看答案&解析
单项选择题
有以下程序: #include <iostream> #include <string> using namespace std; class Y; class X private: int x; char *strx; public: X(int a, char *str) x=a; strx=new char[strlen(str)+1]; strcpy(strx,str); void show(Y &ob) ; ; class Y private: int y; char *stry; public: Y(int b,char *str) y=b; stry=new char[strlen(str)+1]; strcpy(stry, str); friend void X: :show(Y &ob) ; ; void X: :show(Y &ob) cout<<strx<< , ; cout<<ob, stry<<end1; int main ( ) X a(10, X ); Y b (20, Y ); a. show(B) ; return 0; 执行后的输出结果是( )。
A.X,Y
B.a,b
C.X,X
D.Y,Y
点击查看答案&解析
相关试题
下面程序的预设功能是:统计文件abc.txt中...
有如下程序: #include <iostream> u...
有以下程序: #include <iostream> u...
C++中,设置虚基类的目的是 【10】 。
虚函数必须是类的 【12】 。