单选题函数swap(a,n)可完成对a数组从第1个元素到 第 n 个元素两两交换。 其中 b[0]=1;b[1]=2;swap(b,2)。在运行调用函数中的 语句后,b[0]和b[1]的值分别为( )。
单选题在下列函数原型中,可以作为类AA构造函数的是( )。 A) void AA(int); B) int AA(); C) AA(int)const; D) AA (int);
单选题已知int a,b; 用语句scanf("%d%d", 输入a,b的值时,不能作为输入数据分隔符的是
单选题下面程序的输出结果为( )。
#include
class TestClass
{
public:
TestClass(){Val++;}
static int val;
};
int TestClass::val=0:
void main()
{TestClass csl;
cout<
单选题有下列程序: #include<stdio.h> void fun(char *a,char *b) while(*a=='*')a++; while(*b=*a)b++;a++; void main() char *s="*****a*b****",t[80]; fun(s,t);puts(t) 程序的运行结果是( )。
单选题当一个类的某个函数被说明为virtual时,该函数在该类的所有派生类中 ______。
单选题下列循环语句中有语法错误的是______。
单选题执行语句序列 int x=1,&y=x; cout<
单选题在函数声明中,下面哪项是不必要的( )。
单选题下面程序的输出结果是( )。 #include<iostream> using namespace std; void main() int a=18; int * p= cout<<* p;
单选题某二叉树中有n个度为2的结点,则该二叉树中的叶子结点数为( )。
单选题程序中有语句:for(int i=0;i<5;i++)cout<<*(p+i)<<",";能够依次输出int型一维数组a的前5个元素。由此可知,变量P的定义及初始化语句是______。
单选题有如下程序: #include <iostream> using namespace std; class test{ private: int a; public: test( ){cout<<"constructor"<<endl;} test(int A) {cout<<a<<endl;} test(const test &_test){ a=_test.a; cout<<"copy constructor"<<endl; } ~test(){cout<<"destructor"<<endl;} }; int main( ){ test A(3) return 0; } 程序的输出结果是
单选题有如下程序:
#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*p=new B;
p->func1();
p->func2();
delete p;
return 0;
}
执行这个程序的输出结果是______。
单选题若二叉树中度为2的结点有15个,度为1的结点有10个,则有 ______ 个叶结点。 A) 25 B) 30 C) 31 D) 16
单选题有如下程序: #include<iostream> using namespace std; class TestClass private: int x,y; public: TestClass (int i,int j) x=i; y=j; void print() cout<<"print1"<<end1; void print()const cout<<"print2"<<end1; ; int main() const TestClass a(1,2); a.print(); return 0; 该程序运行后的输出结果是( )。
单选题下面选项中,不属于C++语句的是( )。
单选题有以下程序: #include<iostream> using namespace std; #define PI 3.14 class Point private: int x,y; public: Point(int a,int b) x=a; y=b; int getx() return x; int gety() return y;; class Circle:public Point private: int r; public: Circle(int a,int b,int c):Point(a,b) r=c; int getr() return r; double area() return PI *r *r;; int main() Circle c1(5,7,10); cout<<c1.area()<<endl; return 0; 程序执行后的输出结果是( )。
单选题有关构造函数的说法不正确的是
____
。
单选题下面程序的运行结果为______。
#include<iostream>
using namespace std;
class A
{
static int n;
public:
A(){n=1;}
A(int num){n=num;}
void print(){cout<<n;}
};
int A::n=2;
void main()
{
A a, b(3);
a.print();
b.print();
cout<<endl;
}