单选题有以下程序:#include <iostream>using namespace std;class sample{private: int x; static int y;public: sample(int a) ; static void print(sample s);};sample:: sample(int a) { x=a; y+=x;}void sample::print(sample s){ cout<< "x="<<s. x<<", y="<< y<<end1;}int sampte::y=0;int main(){ sample s1(10); sample s2(20); sample::print(s2); return 0;}程序运行后的输出结果是
单选题下列关于运算符重载的描述中,错误的是______。
单选题下面程序的运行结果为
#include<iostream.h>
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;
}
A) 11 B) 13 C) 23 D) 33
单选题有如下函数定义:
void func(int a,intb++;}
若执行代码段:
int x=0,y=1;
func(x,y);
则变量x和y的值分别是______。
单选题以下程序的输出是( )。 struct st int x;int *y; *p; int dt[4]=10,20,30,40; struct st aa[4]= 50, main() p=aa; cout<<++p->x; cout<<(++p)->x; couk<++(*p->y); A.10 20 20 B.50 60 21 C.51 60 21 D.60 70 31
单选题已知递归函数fun的定义如下: int fun(int n) {if(n<=1)return 1;//递归结束情况 else return n*fun(n-2);//递归 } 则函数调用语句fun(5)的返回值是( )。
单选题下面不属于软件设计原则的是 A) 抽象 B) 模块化 C) 自底向上 D) 信息隐蔽
单选题有如下类定义:
class MyClass
{
public:
private:
int data;
};
若要为MyClass类重载流输入运算符“>>”,使得程序中可以“cin>>obj;”的形式改变MyClass类的对象obj中数据成员data的值,则横线处的声明语句应为______。
单选题有以下程序: #include <iostream> using namespace std; class Point' { public: void SetPoint(int x,int y); void Move(int xOff,int yOff); int GetX() { return X; } int GetY() { return Y; } private: int X,Y; }; void Point::SetPoint(int x, int y) { X=x; Y=y; } void Point: :Move(int xOff, int yOff) X+=xOff; Y+=yOff; } int main () { Point p1; p1.SetPoint(1,2); p1.Move (5, 6); cout<<"Point1 is ("<<p1.GetX()<<','<<p1.GetY()<<")"<<end1; return 0; } 执行后的输出结果是( )。
单选题关于getline()函数的下列描述中,错误的是( )。
单选题一个工作人员可使用多台计算机,而一台计算机被多个人使用,则实体工作人员与实体计算机之间的联系是
单选题要通过函数实现一种不太复杂的功能,并且要求加快执行速度,则应该选用
A. 重载函数
B. 内联函数
C. 静态函数
D. 虚函数
单选题if语句的语法格式可描述为
格式1:if()
或
格式2:if()else
关于上面的语法格式,下列表述中错误的是【 】
单选题语句cout<<setprecision(2)<<1024.4567;的输出结果为
单选题下列符号中能够作为C++标识符的是( )。
单选题软件设计中模块划分应遵循的准则是( )。
单选题在数据库系统的组织结构中,下列( )映射把用户数据库与概念数据库联系了起来。
单选题有如下程序:
#include
#include
using namespace std;
class Father{
public:
Father(string s):name(s) { cout<<'F'; }
~Father() { }
private:
string name;
};
class Mother{
public:
Mother(string s):name(s) { cout<<'M'; }
~Mother() { }
private:
string name;
};
class Child:public Mother,public Father{
public:
Child(string s1,string s2,string s3,int a):Father(s1),Mother(s2),name(s3),age(a) { cout<<'C'; }
~Child() { }
private:
string name;
int age;
};
int main(){
Child son("Zhang","Li","Ming",20);
return 0;
}
运行时的输出结果是
单选题下列关于运算符重载的描述中, ______ 是正确的。
单选题静态数据成员是为( )的数据。