早教吧作业答案频道 -->其他-->
英文更佳1.WhatdoesinheritancemeaninC++?SupposeyouhaveclassAandclassB,underwhichofthefollowingtwoconditionsclassBshouldinheritfromclass(1)AisapartofB.(2)BisakindofA.2.Whenshouldthekeywordvirtualbepl
题目详情
英文更佳
1.What does inheritance mean in C++?Suppose you have class A and class B,under which of the following two conditions class B should inherit from class
(1)A is a part of B.
(2)B is a kind of A.
2.When should the keyword virtual be placed before a member function of a class?Do all of the virtual member functions have to be overridden in the derived class?If not,why?
3.Does C++ support multiple inheritance?Some people think that multiple inheritance can cause a variety of ambiguity problems.Try to explain what problems will multiple inheritance cause and how to avoid them.
3.What operators cannot be overloaded in C++?What restriction applies to overloading the following operators?
=,( ),[ ],and ->.
cout
1.What does inheritance mean in C++?Suppose you have class A and class B,under which of the following two conditions class B should inherit from class
(1)A is a part of B.
(2)B is a kind of A.
2.When should the keyword virtual be placed before a member function of a class?Do all of the virtual member functions have to be overridden in the derived class?If not,why?
3.Does C++ support multiple inheritance?Some people think that multiple inheritance can cause a variety of ambiguity problems.Try to explain what problems will multiple inheritance cause and how to avoid them.
3.What operators cannot be overloaded in C++?What restriction applies to overloading the following operators?
=,( ),[ ],and ->.
cout
▼优质解答
答案和解析
1、(2),B是A的特例,因为B有A的非静态方法和成员
2、virtual public Class A{} publicvirtual Class A{} virtual void print().
对于不需要virtual void print() const=0;的定义,如果没有重载,继承的类或者函数依然是virtual函数,需要在其某个后代中完全被重载才可以直接实例化,否则不能用.
3、有、会、解决方法C obj;obj.A::func();
3、C/C++ 里大多数运算符都可以在 C++ 中被重载.只有 . 和 ? :和::和.*不可被重载,此外 sizeof()也不可以被重载.限制是:该组重载函数中任何两个都必须有不同的参量表.具有相同类型参量表、仅在返回值类型上不同的重载函数会引起错误.
2、virtual public Class A{} publicvirtual Class A{} virtual void print().
对于不需要virtual void print() const=0;的定义,如果没有重载,继承的类或者函数依然是virtual函数,需要在其某个后代中完全被重载才可以直接实例化,否则不能用.
3、有、会、解决方法C obj;obj.A::func();
3、C/C++ 里大多数运算符都可以在 C++ 中被重载.只有 . 和 ? :和::和.*不可被重载,此外 sizeof()也不可以被重载.限制是:该组重载函数中任何两个都必须有不同的参量表.具有相同类型参量表、仅在返回值类型上不同的重载函数会引起错误.
看了 英文更佳1.Whatdoes...的网友还看了以下:
英文更佳1.WhatdoesinheritancemeaninC++?Supposeyouhave 2020-04-06 …
固定化细胞技术与固定化酶技术相比,所具备的特点是()A、成本更低、操作更容易、不能连续性生产B、成 2020-04-12 …
背东西理解东西的时候,怎么样才能更效率,而且看书怎么样能看的更快记的更牢快点看心无杂念的能更效率吗 2020-04-27 …
更快,更高,更强的英语说法更高,更快,更强用英语怎么说? 2020-05-13 …
D地区葡萄种植的经济效益比C地区更好的原因可能是()A.D地区昼夜温差更大,葡萄质量更好B.D地区 2020-05-14 …
急求这几道c++题的答案,英文更佳1.WhatdoesinheritancemeaninC++?S 2020-06-20 …
有人说:现在,我们比以前吃的更好、更有营养;“穿”的比以前更美、更有个性;“住”的比以前更宽敞、更 2020-06-26 …
2^5/2-2^3/2=?我算出来等于22^5/2=2^5再开更号,等于更号32=4倍更号22^3 2020-07-22 …
打更的更和三更半夜的更有什么不同?打更我们读gēng,但是三更半夜我们又读jīng.为什么更在这里 2020-07-23 …
英语翻译我们付出的更多,享受到的却更少;我们的住房更大,但我们的家庭却更小;我们做出的让步更多,但是 2020-12-10 …