A: cout<<*p
B: cout<
C: cout<<&p
D: cout<<(void*)p
举一反三
- 假定p指向的字符串为”string”,若要输出这个字符串的地址值,则使用()。 A: cout< B: cout< C: cout< D: cout
- 中国大学MOOC: 假定p指向的字符串为string,则cout<<p+3的输出结果为ing
- 中国大学MOOC: 下列程序的运行结果是 。 #include<iostream>using namespace std;char *fun(char *str, char c){ while ( *str!=’\0’) if(*str==c) return (str); else str++; return (NULL);}void main(){ char s [80] = “warrior”, *p; p=fun(s, ‘r’); if(p) cout<<p<<endl;p=fun(s, ‘i’); if(p) cout<<p<<endl;p=fun(s, ‘b’); if(p) cout<<p<<endl;}
- char *p="a string";该语句使指针变量p指向字符串“a string”,通过p可访问“a string”字符串的任何字符
- 有如下程序: #include<iostream> using namespace std; class A public: virtual void func1()cout<<"A1"; void func2()cout<<"A2"; ; class B:public A public: void func1()cout<<"B1"; void func2()cout<<"B2"; ; int main() A: A*p=new B; B: p->func1(); C: p->func2(); D: delete p; E: retum 0;执行这个程序的输出结果是______。A.B1B2 F: A1A2 G: B1A2 H: A1B2
内容
- 0
写出程序运行结果:_________ #include <iostream.h> class Bas { public: ~Bas() { cout<<"Bas construct"<<endl; } virtual void f()=0; }; class Dev:public Bas { public: ~Dev() { cout<<"Bas construct"<<endl; } virtual void f() { cout<<"Dev::f"<<endl; } }; void main() { Bas *a; Dev p; a=&p; a->f(); }
- 1
下面的程序段的运行结果为?char str[] = "job", *p = str;cout A: 字符’b’ B: 无输出结果 C: 字符’b’的地址 D: 98
- 2
下面程序的输出结果是( )。 #include<iostream> using namespace std; void main() { int a=18; int * p=&a; cout<<* p;} A: 18 B: 以十进制输出变量a的地址 C: 以十进制输出p的地址 D: 以十六进制输出a的地址
- 3
下列程序的执行结果是___________。 #include[iostream.h] class A { public: A() { cout[<endl<<"实例化类A的一个对象。"; } virtual ~A() { cout<<endl<<"消除类A的一个对象。"; } virtual void f() { cout<<endl<<"执行类A的成员函数。"; } }; class B:public A { public: B() { cout<<endl<<"事例化类B的一个对象。"; } virtual ~B() { cout<<endl<<"消除类B的一个对象。"; } void f() { cout<<endl<<"执行类B的成员函数。"; } }; void main() { A a=A(); B b=B(); cout<<endl<<"----------"; a.f(); b.f(); cout<<endl<<"----------"; A *p; p=&b; p-]f(); cout<<endl<<"----------"; }
- 4
假定s指向的字符串为”string”,若要输出这个字符串的地址值,则使用