已知基类Employee只有一个构造函数,其定义如下: Employee::Employee(int n):id(n){ } Manager是Employee的派生类,则下列对Manager的构造函数的定义中,正确的是?A.Manager::Manager(int n):id(n){}B.Manager::Manager(int n){id=n;}C.Manager::Manager(int n):Employee(n){}D.Manager::Manager(int n){Employee(n);}
已知基类Employee只有一个构造函数,其定义如下: Employee::Employee(int n):id(n){ } Manager是Employee的派生类,则下列对Manager的构造函数的定义中,正确的是?
A.Manager::Manager(int n):id(n){}
B.Manager::Manager(int n){id=n;}
C.Manager::Manager(int n):Employee(n){}
D.Manager::Manager(int n){Employee(n);}
参考答案和解析
Manger::manger(int n):Employee(n){}
相关考题:
( 13 )下列关于派生类构造函数和析构函数的说法中,错误的是A )派生类的构造函数会隐含调用基类的构造函数B )如果基类中没有缺省构造函数,那么派生类必须定义构造函数C )在建立派生类对象时,先调用基类的构造函数,再调用派生类的构造函数D )在销毁派生类对象时,先调用基类的析构函数,再调用派生类的析构函数
●试题五阅读下列程序说明,将应填入(n)处的字句写在答卷纸的对应栏内。【程序说明】对于一个公司的雇员来说,无非有3种:普通雇员、管理人员和主管。这些雇员有共同的数据:名字、每小时的工资,也有一些共同的操作:数据成员初始化、读雇员的数据成员及计算雇员的工资。但是,他们也有不同。例如,管理人员除有这些共同的特征外,有可能付固定薪水,主管除有管理人员的共同特征外,还有其他物质奖励等。3种雇员中,管理人员可以看作普通雇员的一种,而主管又可以看作管理人员的一种。我们很容易想到使用类继承来实现这个问题:普通雇员作为基类,管理人员类从普通雇员类中派生,而主管人员类又从管理人员类中派生。下面的程序1完成上述各个类的定义,并建立了3个雇员(一个普通雇员、一个管理人员和一个主管)的档案,并打印出各自的工资表。将"程序1"中的成员函数定义为内联函数,pay成员函数定义为虚函数,重新完成上述要求。【程序1】//普通雇员类class Employee{public:Employee(char*theName,float thePayRate);char*getName()const;float getPayRate()const;float pay(float hoursWorked)const;protected:char*name;//雇员名称float payRate;//薪水等级};Employee::Employee(char*theName,float thePayRate){name=theName;payRate=thePayRate;}char*Employee::getName() const{return name;}float Employee::getPayRate()const{return payRate;}float Employee::pay(float hoursWorked)const{return hoursWorked*payRate;}//管理人员类class Manager∶public Employee{public://isSalaried付薪方式:true付薪固定工资,false按小时付薪Manager(char*theName,float thePayRate,bool isSalaried);bool getSalaried()const;float pay(float hoursWorked)const;protected:bool salaried;};Manager::Manager(char*theName,float thePayRate,bool isSalaried)∶Employee(theName,thePayRate){salaried=isSalaried;}bool Manager::getSalaried() const{return salaried;}float Manager::pay(float hoursWorked)const{if(salaried)return payRate;/*else*/return Employee::pay(hoursWorked);}//主管人员类class Supervisor:public Employee{public:Supervisor(char*theName,float thePayRate,float theBouns):Employee(theName,thePayRate, (1) ),bouns(theBouns){}float getBouns()const{return bouns;}float pay(float hoursWorked)constreturn (2) ;}protected:float bouns;}#include"iostream.h"void main(){Employee e("Jack",50.00);Manager m("Tom",8000.00,true);Supervior s("Tanya",8000.00,8000.00);cout"Name:"e.getName()endl;cout"Pay:"e.pay(80)endl;//设每月工作80小时cout"Name:"m.getName()endl;cout"Pay:"m.pay (40) endl;cout"Name:"s.getName()endl;cout"Pay:"s.pay (40) endl;//参数40在这里不起作用}【程序2】#include"employee.h"//普通雇员类class Employee{public://构造函数Employee(string theName,float thePayRate):name(theName),payRate(thePayRate){}//取雇员姓名string getName() const{returnname;}//取雇员薪水等级float getPayRate()const{return payRate;}//计算雇员薪水virtual float pay(float hoursWorked)const{return (3) ;}protected:string name;//雇员名称float payRate;//薪水等级};//管理人员类//继承普通雇员类class Manager:public Employee{public://构造函数//isSalaried标识管理人员类的付薪方式//true 按阶段付薪(固定工资)//false按小时付薪Manager(string theName,float thePayRate,bool isSalaried):Employee(theName,thePayRate),salaried(isSalaried){}//取付薪方式bool getSalaried()const{return salaried;}//计算薪水virtual float pay(float (4) )const;protected:bool salaried;};float Manager::pay(float hoursWorked)const{if(salaried)//固定付薪方式return payRate;else//按小时付薪return (5) ; }//主管人员类class Supervisor: (6){public://构造函数Supervisor(string theName,float thePayRate,float theBouns):Manager(theName,thePayRate,true),bouns(theBouns){}//取奖金数额float getBouns()const{return bouns;}//计算薪水virtual float pay(float hoursWorked)const{retum payRate+bouns;}(7)float bouns;}#include"employee.h"#include"iostream.h"void main(){(8) *ep[3];ep[0]=new Employee("Jack","50.00");ep[1]=new Manager("Tom","8000.00",true);ep[2]=new Supervior("Tanya","8000.00","8000.00");for(int i=0;i3;i++){cout"Name:" (9) endl;cout"Pay:" (10) endl;//设每月工作80小时}}
下列关于派生类的构造函数的叙述中,正确的是( )。A.派生类通过成员初设列表的方法调用基类的构造函数,实现对基类的初始化B.派生类构造函数的调用顺序先基类后子对象构造函数C.派生类构造函数的调用顺序先子对象构造函数后基类,D.派生类构造函数是不能继承基类的
Examine the data of the EMPLOYEES table.EMPLOYEES (EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers and refers to the EMPLOYEE_ID)Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee‘s manager, for all the employees who have a manager and earn more than 4000?()A.B.C.D.E.
生成派生类对象时,派生类构造函数调用基类构造函数的条件是( )。A) 无需任何条件B) 基类中显示定义了构造函数C) 派生类中显式定义了构造函数D) 派生类构造函数明确调用了基类构造函数A.B.C.D.
下列关于派生类的构造函数的叙述中,正确的是( )。A.派生类通过成员初设列表的方法调用基本类的构造函数,实现对基本类的初始化B.派生类构造函数的调用顺序先基类后子对象构造函数C.派生类构造函数的调用顺序先子对象构造函数后基类D.派生类构造函数是不能继承基类的
阅读和理解下面程序段: class Manager extends Employee{ public Manager(String n,double s,int year,int month,int day){ super(n,s,year,month,day); bonus=0; } public double getSalary(){ double baseSalary-super.gerSalary(); return baseSalary+bonus; } public void setBonus(double b){bonus=b; ) private double bonus; } Manager是Employee的子类,其理由是( )。A.Manager的适用范围较宽B.extends关键字声明C.Manager的域减小了D.雇员是一个经理
已知:Manager extends Employee观察:public Manager(String n,double s,int year,int month,int day) { super(n,s,year,month,day); bonus=0; }其中super是 ( )A.Object类B.Manager类C.Employee类D.Class类
使用VC6打开考生文件夹下的工程test18_3,此工程包含一个源程序文件test18_3.cpp,其中定义了用于表示雇员的类 Employee,但类Employee的定义并不完整。请按要求完成下列操作,将类Employee的定义补充完整。(1)补充类Employee的构造函数,请使用字符串函数将数据成员name,address,city,province和zipcode分别初始化为参数*nm,*addr,*city,*prov和*zip的值。请在注释“//**1**”之后添加适当的语句;(2)完成类Employee的成员函数ChangeName(char * newName)的定义,将newName指向的内容赋值给数据成员name,请在注释“//**2**”之后添加适当的语句;(3)完成类Employee的成员函数Display()的定义,先使用指针buffer动态申请一个char型的200单位大小的空间,然后使用字符串函数将数据成员name和address依次复制其中,最后返回该指针buffer,将请在注释“//**3**”之后添加适当的语句。输出结果如下:王东建国路大街105号注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。源程序文件test18_3.cpp清单如下:include <iostream.h>include <string.h>class Employee{protected:char name[20];char address[100];char city[20];char province[20];char zipcode[10];public:Employee(char *nm, char *addr,char *city, char *prov, char *zip);void ChangeName(char *newName);char *Display();};Employee::Employee(char *nm, char *adr, char *cit, char *prov, char *zip){//**1**strcpy(city, cit);strcpy(province,prov);strcpy(zipcode,zip);}void Employee::ChangeName(char * newName){//**2**}char *Employee::Display(){//**3**strcat(buffer, address);return buffer;}void main(){Employee emp("李华","建国路大街105号","石家庄","河北","103400");emp. ChangeName ("王东");cout<<emp.Display()<<end1;}
已知类的继承关系如下:class Employee;class Manager extends Employeer;class Director extends Employee;则以下语句能通过编译的有哪些? A.Employee e=new Manager();B.Director d=new Manager();C.Director d=new Employee();D.Manager m=new Director();
Click the Exhibit button to examine the data of the EMPLOYEES table.Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee‘s manager, for all the employees who have a manager and earn more than 4000?()A.SELECT employee_id Emp_id, emp_name Employee, salary, employee_id Mgr_id, emp_name Manager FROM employees WHERE salary 4000;B.SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary, m.employee_id Mgr_id, m.emp_name Manager FROM employees e JOIN employees m WHERE e.mgr_id = m.mgr_id AND e.salary 4000;C.SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary, m.employee_id Mgr_id, m.emp_name Manager FROM employees e JOIN employees m ON (e.mgr_id = m.employee_id) AND e.salary 4000;D.SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary, m.mgr_id Mgr_id, m.emp_name Manager FROM employees e SELF JOIN employees m WHERE e.mgr_id = m.employee_id AND e.salary 4000;E.SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary, m.mgr_id Mgr_id m.emp_name Manager FROM employees e JOIN employees m USING (e.employee_id = m.employee_id) AND e.salary 4000;
public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } } 执行语句new Manager(“smith”)后程序的输出是哪项?() A、 smithB、 nullC、 编译错误D、 name
下列哪一种顺序是派生类构造函数正确的调用其它构造函数顺序。()A、基类构造函数—对象成员所在类的构造函数—派生类自己的构造函数初始化自定义数据成员B、基类构造函数—派生类自己的构造函数初始化自定义数据成员—对象成员所在类的构造函数C、派生类自己的构造函数初始化自定义数据成员—对象成员所在类的构造函数—基类构造函数D、对象成员所在类的构造函数—派生类自己的构造函数初始化自定义数据成员—基类构造函数
在C#中,假设Person是一个类,而ITeller是一个接口,下面的()类声明是正确的。A、class Employee:Person,ITeller B、class Employee:ITeller,PersonC、class Employee-Person,ITellerD、class Employee:Person / ITeller
在Person的一个派生类Employee里调用Person类的构造函数正确方式为()。A、base.Person(name,age)B、base(name,age)C、Person(name,age)D、this(name,age)
Examine the data of the EMPLOYEES table. EMPLOYEES (EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers and refers to the EMPLOYEE_ID) EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY EMPLOYEE_ID 101 Smith 20 120 SA_REP 4000 102 Martin 10 105 CLERK 2500 103 Chris 20 120 IT_ADMIN 4200 104 John 30 108 HR_CLERK 2500 105 Diana 30 108 HR_MGR 5000 106 Bryan 40 110 AD_ASST 3000 108 Jennifer 30 110 HR_DIR 6500 110 Bob 40 EX_DIR 8000 120 Ravi 20 110 SA_DIR 6500 Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee's manager, for all the employees who have a manager and earn more than 4000?()A、SELECT employee_id "Emp_id", emp_name "Employee", salary, employee_id "Mgr_id", emp_name "Manager" FROM employees WHERE salary 4000;B、SELECT e.employee_id "Emp_id", e.emp_name "Employee",C、salary,D、employee_id "Mgr_id", m.emp_name "Manager" FROM employees e, employees m WHERE e.mgr_id = m.mgr_id AND e.salary 4000;
You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES and DEPARTMENTS tables: EMPLOYEE_ID, EMPLOYEE_NAME AND DEPARTMENT_NAME. The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key DEPARTMENT_ID column of the DEPARTMENTS table. You want to modify the view by adding a fourth column, MANAGER_ID of NUMBER data type from the EMPLOYEES tables. How can you accomplish this task?()A、ALTER VIEW emp_dept_vu (ADD manager_id NUMBER);B、MODIFY VIEW emp_dept_vu (ADD manager_id NUMBER);C、ALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employee e, departments d WHERE e.department_id = d.department_id;D、MODIFY VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;E、CREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;F、You must remove the existing view first, and then run the CREATE VIEW command with a new column list to modify a view.
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ this.department = department; super(name); System.out.println(getName()); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smithB nullC SALESD 编译错误
单选题下列哪一种顺序是派生类构造函数正确的调用其它构造函数顺序。()A基类构造函数—对象成员所在类的构造函数—派生类自己的构造函数初始化自定义数据成员B基类构造函数—派生类自己的构造函数初始化自定义数据成员—对象成员所在类的构造函数C派生类自己的构造函数初始化自定义数据成员—对象成员所在类的构造函数—基类构造函数D对象成员所在类的构造函数—派生类自己的构造函数初始化自定义数据成员—基类构造函数
单选题您在公司的数据库中成功创建了名为SALARY的表。您现在要通过向引用EMPLOYEES表的匹配列的SALARY表添加FOREIGNKEY约束条件来建立EMPLOYEES表与SALARY表之间的父/子关系。尚未向SALARY表添加任何数据。应执行以下哪条语句()AALTER TABLE salary ADD CONSTRAINT fk_employee_id_01 FOREIGN KEY(employee_id)REFERENCES employees(employee_id)BALTER TABLE salary ADD CONSTRAINT fk_employee_id_ FOREIGN KEY BETWEEN salary(employee_id)AND employees(employee_id)CALTER TABLE salary FOREIGN KEY CONSTRAINT fk_employee_id_REFERENCES employees(employee_id)DALTER TABLE salary ADD CONSTRAINT fk_employee_id_FOREIGN KEY salary(employee_id)=employees(employee_id)
单选题在创建派生类对象时,构造函数的执行顺序是()A对象成员构造函数―基类构造函数―派生类本身的构造函数B派生类本身的构造函数―基类构造函数―对象成员构造函数C基类构造函数―派生类本身的构造函数―对象成员构造函数D基类构造函数―对象成员构造函数―派生类本身的构造函数
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } } 执行语句new Manager(“smith”)后程序的输出是哪项?()A smithB nullC 编译错误D name
单选题在Person的一个派生类Employee里调用Person类的构造函数正确方式为()。Abase.Person(name,age)Bbase(name,age)CPerson(name,age)Dthis(name,age)
单选题You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES and DEPARTMENTS tables: EMPLOYEE_ID, EMPLOYEE_NAME AND DEPARTMENT_NAME. The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key DEPARTMENT_ID column of the DEPARTMENTS table. You want to modify the view by adding a fourth column, MANAGER_ID of NUMBER data type from the EMPLOYEES tables. How can you accomplish this task?()AALTER VIEW EMP_dept_vu (ADD manger_id NUMBER);BMODIFY VIEW EMP_dept_vu (ADD manger_id NUMBER);CALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employee e, departments d WHERE e.department _ id = d.department_id;DMODIFY VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department _ id = d.department_id;ECREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department _ id = d.department_id;FYou must remove the existing view first, and then run the CREATE VIEW command with a new column list to modify a view.
单选题下列选项中,能实现对父类的getSalary方法重写的是( )。class Employee{public double getSalary(){}}Aclass Manager extends Employee{public int getSalary(double x){}}Bclass Manager extends Employee{public double getSalary(int x,int y){}}Cclass Manager extends Employee{public double getSalary(){}}Dclass Manager extends Employee{public int getSalary(int x,int y){}}
单选题评估EMPLOYEE表的结构: EMPLOYEE_IDNUMBER(9) LAST_NAMEVARCHAR2(25) FIRST_NAMEVARCHAR2(25) DEPARTMENT_IDNUMBER(9) MANAGER_IDNUMBER(9) SALARYNUMBER(7,2) EMPLOYEE_ID列当前包含500个雇员标识号。业务需求已发生变化,您需要允许用户在标识值中包含文本字符。应该使用哪条语句来更改该列的数据类型()AALTER TABLE employee MODIFY(employee_id VARCHAR2(9))BALTER TABLE employee REPLACE(employee_id VARCHAR2(9))CALTER employee TABLEMODIFY COLUMN(employee_id VARCHAR2(15))D您不能修改EMPLOYEE_ID列的数据类型,因为该表不为空
单选题Examine the data of the EMPLOYEES table. EMPLOYEES (EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers and refers to the EMPLOYEE_ID) EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY EMPLOYEE_ID 101 Smith 20 120 SA_REP 4000 102 Martin 10 105 CLERK 2500 103 Chris 20 120 IT_ADMIN 4200 104 John 30 108 HR_CLERK 2500 105 Diana 30 108 HR_MGR 5000 106 Bryan 40 110 AD_ASST 3000 108 Jennifer 30 110 HR_DIR 6500 110 Bob 40 EX_DIR 8000 120 Ravi 20 110 SA_DIR 6500 Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee's manager, for all the employees who have a manager and earn more than 4000?()ASELECT employee_id Emp_id, emp_name Employee, salary, employee_id Mgr_id, emp_name Manager FROM employees WHERE salary 4000;BSELECT e.employee_id Emp_id, e.emp_name Employee,Csalary,Demployee_id Mgr_id, m.emp_name Manager FROM employees e, employees m WHERE e.mgr_id = m.mgr_id AND e.salary 4000;