2. 已知有职工情况结构变量emp定义为: struct Date { int year; int month; int day; }; strnct Employee { char name[20] ; long code ; Date birth }; Employee emp ; 下列对emp的birth的正确赋值方法是( )。 (A) year=1980; month=5; day=1; (B) birth.year=1980; birth.month=5; birth.day=1; (C) emp.year=1980; emp.month=5; emp.day=1; (D) emp.birth.year=1980; emp.birth.month=5; emp.birth.day=1; 参考答案:D 3. s1和s2是两个结构类型变量,若要赋值s1=s2合法,则它们的说明应该是( )。 (A) s1只能接受相同类型的数据成员 (B) 结构中的成员相同 (C) 同一结构类型的变量 (D) 存储字节长度一样的变量 答题: A. B. C. D. (已提交) 参考答案:C 4. 若有以下说明语句,则下列错误的引用是( )。 struct Worker { int no; char name[20]; }; Worker w, *p = &w ; (A) w.no (B) p->no (C) (*p).no (D) *p.no 参考答案:D 类与对象·5.2 类与对象 1. 有变量说明 struct ptype{int x; int y; } ptype point[3]={ 1,2,3,4,5,6 }, *p=point; 以下不正确的引用是:( ) (A) (++p).x (B) point[1].y (C) (p++)->x (D) (*p).y 参考答案:A 2. 假定有以下说明语句,则下面引用形式错误的是( )。 struct Student { int num ; double score ; }; Student stu[3]={{1001,80}, {1002,75}, {1003,91}}, *p=stu ; (A) p->num (B) (p++).num (C) (p++)->num (D) (*p).num 参考答案:B 第5章 类与对象·5.3 构造函数和析构函数 1. 以下关于链表的说法错误的是:
(A)结点肯定包含指针 (B) 可以包含多种类型的数据
(C)起码包含一个结点 (D) 理论上数据量不受限制
参考答案:C