ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:128.52KB ,
资源ID:4164496      下载积分:1 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-4164496.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C++常见英文面试笔试题.docx)为本站会员(b****3)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

C++常见英文面试笔试题.docx

1、C+常见英文面试笔试题C/C+ Programming interview questions and answers By Satish Shetty, July 14th, 2004What is encapsulation?Containing and hiding information about an object, such as internal data structures and code. Encapsulation isolates(使隔离) the internal complexity of an objects operation from the rest o

2、f the application. For example, a client component asking for net revenue(收益) from a business object need not know the datas origin.What is inheritance?Inheritance allows one class to reuse the state and behavior of another class. The derived class inherits the properties and method implementations

3、of the base class and extends it by overriding methods and adding additional properties and methods.What is Polymorphism?Polymorphism allows a client to treat different objects in the same way even if they were created from different classes and exhibit(展现) different behaviors.You can use implementa

4、tion(实现) inheritance to achieve polymorphism in languages such as C+ and Java.Base class objects pointer can invoke(调用) methods in derived class objects.You can also achieve polymorphism in C+ by function overloading and operator overloading.What is constructor or ctor?Constructor creates an object

5、and initializes it. It also creates vtable变量列表? for virtual functions. It is different from other methods in a class.What is destructor?Destructor usually deletes any extra resources allocated by the object. What is default constructor?Constructor with no arguments or all the arguments has default v

6、alues.What is copy constructor?Constructor which initializes the its object member variables ( by shallow copying) with another object of the same class. If you dont implement one in your class then compiler implements one for you.for example:Boo Obj1(10); / calling Boo constructorBoo Obj2(Obj1); /

7、calling boo copy constructorBoo Obj2 = Obj1;/ calling boo copy constructorWhen are copy constructors called? Copy constructors are called in following cases: a) when a function returns an object of that class by valueb) when the object of that class is passed by value as an argument to a functionc)

8、when you construct an object based on another object of the same classd) When compiler generates a temporary objectWhat is assignment operator? Default assignment operator handles assigning one object to another of the same class. Member to member copy (shallow copy)What are all the implicit member

9、functions of the class? Or what are all the functions which compiler implements for us if we dont define one.?default ctorcopy ctorassignment operatordefault destructoraddress operatorWhat is conversion constructor?constructor with a single argument makes that constructor as conversion ctor and it c

10、an be used for type conversion.for example:class Boo public: Boo( int i );Boo BooObject = 10 ; / assigning int 10 Boo objectWhat is conversion operator?class can have a public method for specific data type conversions.for example:class Boo double value; public: Boo(int i ) operator double() return v

11、alue; ;Boo BooObject;double i = BooObject; / assigning object to variable i of type double. now conversion operator gets called to assign the value.What is diff between malloc()/free() and new/delete?malloc allocates memory for object in heap but doesnt invoke objects constructor to initiallize the

12、object.new allocates memory and also invokes constructor to initialize the object.malloc() and free() do not support object semantics Does not construct and destruct objects string * ptr = (string *)(malloc (sizeof(string)Are not safe Does not calculate the size of the objects that it construct Retu

13、rns a pointer to void int *p = (int *) (malloc(sizeof(int);int *p = new int;Are not extensible new and delete can be overloaded in a class delete first calls the objects termination routine (i.e. its destructor) and then releases the space the object occupied on the heap memory. If an array of objec

14、ts was created using new, then delete must be told that it is dealing with an array by preceding the name with an empty :-Int_t *my_ints = new Int_t10;.delete my_ints;what is the diff between new and operator new ?operator new works like malloc.What is difference between template and macro?There is

15、no way for the compiler to verify that the macro parameters are of compatible types. The macro is expanded without any special type checking.If macro parameter has a post-incremented variable ( like c+ ), the increment is performed two times.Because macros are expanded by the preprocessor, compiler

16、error messages will refer to the expanded macro, rather than the macro definition itself. Also, the macro will show up in expanded form during debugging.for example:Macro:#define min(i, j) (i j ? i : j)template:template T min (T i, T j) return i j ? i : j;What are C+ storage classes?autoregisterstat

17、icexternauto: the default. Variables are automatically created and initialized when they are defined and are destroyed at the end of the block containing their definition. They are not visible outside that blockregister: a type of auto variable. a suggestion to the compiler to use a CPU register for

18、 performancestatic: a variable that is known only in the function that contains its definition but is never destroyed and retains=keep its value between calls to that function. It exists from the time the program begins executionextern: a static variable whose definition and placement is determined

19、when all object and library modules are combined (linked) to form the executable code file. It can be visible outside the file where it is defined.What are storage qualifiers in C+ ?They are.constvolatilemutableConstkeyword indicates that memory once initialized, should not be altered by a program.v

20、olatilekeyword indicates that the value in the memory location can be altered even though nothing in the programcode modifies the contents. for example if you have a pointer to hardware location that contains the time, where hardware changes the value of this pointer variable and not the program. Th

21、e intent of this keyword to improve the optimization ability of the compiler. mutable keyword indicates that particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.struct datachar name80;mutable double salary;cons

22、t data MyStruct = Satish Shetty, 1000 ; /initlized by complierstrcpy ( MyStruct.name, Shilpa Shetty); / compiler errorMyStruct.salaray = 2000 ; / complier is happy allowedWhat is reference ?reference is a name that acts as an alias, or alternative name, for a previously defined variable or an object

23、.prepending variable with & symbol makes it as reference.for example:int a;int &b = a; & 读 amp What is passing by reference?Method of passing arguments to a function which takes parameter of type reference.for example:void swap( int & x, int & y ) int temp = x; x = y; y = temp;int a=2, b=3;swap( a,

24、b );Basically, inside the function there wont be any copy of the arguments x and y instead they refer to original variables a and b. so no extra memory needed to pass arguments and it is more efficient. When do use const reference arguments in function?a) Using const protects you against programming

25、 errors that inadvertently不经意的 alter data.b) Using const allows function to process both const and non-const actual arguments, while a function without const in the prototype can only accept non constant arguments.c) Using a const reference allows the function to generate and use a temporary variabl

26、e appropriately. When are temporary variables created by C+ compiler?Provided that function parameter is a const reference, compiler generates temporary variable in following 2 ways.a) The actual argument is the correct type, but it isnt Lvaluedouble Cube(const double & num) num = num * num * num; r

27、eturn num;double temp = 2.0;double value = cube(3.0 + temp); / argument is a expression and not a Lvalue;b) The actual argument is of the wrong type, but of a type that can be converted to the correct typelong temp = 3L;double value = cuberoot ( temp); / long to double conversion What is virtual fun

28、ction?When derived class overrides the base class method by redefining the same function, then if client wants to access redefined the method from derived class through a pointer from base class object, then you must define this function in base class as virtual function.class parent void Show() cou

29、t im parent endl;class child: public parent void Show() cout im child show() / calls parent-show() i now we goto virtual world.class parent virtual void Show() cout im parent endl;class child: public parent void Show() cout im child show() / calls child-show() What is pure virtual function? or what

30、is abstract class?When you define only function prototype in a base class without implementation and do the complete implementation实现 in derived class. This base class is called abstract class and client wont able to instantiate an object using this base class.You can make a pure virtual function or abstract class this way.class Boovoid foo() = 0;Boo MyBoo; / compilation error What is Memory alignment?The term alignment primarily means the tendency趋向of an address pointer value to be a multiple of some power of two. So a pointer with two byte alignment has a zero in the

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2