Agrave
Bsignificant
Cgrand
Dvital
第1题:
已知学生记录描述为:
struct student
{ int no;
char name[20],sex;
struct
{ int year,month,day;
} birth;
};
struct student s;
设变量s中的"生日"是"1984年11月12日",对"birth"正确赋值的程序段是
A.year=1984;month=11;day=12;
B.s.year=1984;s.month=11;s.day=12;
C.birth.year=1984;birth.month=11;birth.day=12;
D.s.birth.year=1984;s.birth.month=11;s.birth.day=12;
第2题:
使用VC6打开考生文件夹下的工程test28_3。此工程包含一个test28_3.cpp,其中定义了类Person,但该类的定义并不完整。请按要求完成下列操作,将程序补充完整。
(1)定义类Person的私有数据成员forename、surname 和 money,forename 和 surname都是char型的指针数据,money是double型的数据。请在注释“//**1**”之后添加适当的语句。
(2)完成类Person的带三个参数的构造函数Person(char *f, char *s,double m),分别为forename和surname申请新的空间来存储参数f和s指针指向的内容,注意空间的大小,最后把参数m的值赋给money,请在注释“//**2**”之后添加适当的语句。
(3)完成类Person的析构函数的定义,把forename和surname指向的空间释放,请在注释“//**3**”之后添加适当的语句。
(4)完成类Person的成员函数display的定义,使其以格式“forname surname has money”的形式输出内容,请在注释“//**4*。”之后添加适当的语句。
注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。
输出结果如下:
Richard Berk has 1000.56
源程序文件test28_3.cpp清单如下:
include <iostream.h>
include <string.h>
class Person
{
private:
//** 1 **
double money;
public:
Person(char *f, char *s, double m);
~Person();
void display();
};
Person::Person(char *f, char *s, double m)
{
//** 2 **
strcpy(forename, f);
surname = new char[strlen(s)+1];
strcpy(surname, s);
money=m;
}
Person: :-Person ()
{
//** 3 **
}
void Person:: display ( )
{
//** 4 **
}
void main ( )
{
Person p("Richard", "Berk", 1000.56);
p.display ( );
}
第3题:
已知学生记录描述为 struct student { int no; char name[20]; char sex; struct { int year; int month; int day; } birth; }; struct student s;变量s中的“生日”应是“1985年4月4日”,下列对“生日”的正确赋值方式是______。
A.year=1985;month=4;day=4;
B.birth.year=1985;birth.month=4;birth.day=4;
C.s.year=1985;s.month=4;s.day=4;
D.s.birth.year=1985;s.birth.month=4;s.birth,day=4;
第4题:
The Declaration of Inspection made before oil transfer operations must be signed by the ______.
A.Master of the vessel
B.Captain of the Port
C.person(s) in charge
D.All of the above
第5题:
下列程序运行后的输出结果是( )。#include#includeusing namespace std;class Person{public:Person(string n):name(n) { cout<<'P'; }private:string name;};class Date{public:Date(int y=2012,int m=12,int d=21):year(y),month(m),day(d) { cout<<'D'; }
private:int year,month,day;};class Student:public Person{public:Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n) { cout<<'S'; }private:Date birthday;char sex;};int main(){Student stu1("Zhang",1990,10,1,'F');return 0}
A. S
B.PS
C.DPS
D.PDS
第6题:
A、Person’s
B、Mens’
C、Men's
D、Man’s
第7题:
已知学生记录描述为: struct student { int no; char name[20],sex; struct { int year,month,day; } birth; }; struct student s; 设变量s中的“生日”是“1984年11月12日”,对“birth”正确赋值的程序段是( )。
A.year=1984;month=11;day=12;
B.s.year=1984;s.month=11;s.day=12;
C.birth.year=1984;birth.month=11;birth.day=12;
D.s.birth.year=1984;s.birth.month=11;s.birth.day=12;
第8题:
.Thomas Jefferson and John Adams died on July 4,1826,the fiftieth_ ______of American Independence.
A)ceremony B)occasion C)occurrence D)anniversary
托马斯·杰斐逊和约翰·亚当斯死于1826年7月4日,美国独立的五十周年纪念日。
选D
第9题:
某C语言结构体的定义如下。 struct date { int year, month, day; }; struct worklist { char name[20]; char sex; struct date birthday; }person; 若对变量person的出生年份进行赋值,正确的赋值语句是(33)。
A.year=1976
B.birthday. year=1976
C.person. year=1976
D.person. birthday. year=1976
第10题:
已知学生记录描述如下,设变量s中的“生日”应是“1984年11月11日”,下列对生日的正确赋值方式是()。 struct student{ int no; char name[20]; char set; struct{ int year; int month; int day; } birth; }; struct student s;
A.year=1984;month=11;day=11;
B.birth.year=1984; birth.month=11; birth.day=11
C.s.year=1984;s.month=11;s.day=11
D.s.birth.year=1984;s.birth.month=11; s.birth.day=11;