应聘C++职位的开发者提出了36个问题

 1.在C++中,基本数据类型有多少种初始化方式?你能都说出来吗?
  1.直接初始化("()"):又叫做构造函数(constructor)初始化, 是将初始值用小括号(parenthesis ())括起来,
  2.复制初始化("="):又叫做类C (c-like) 方法,是在声明变量的时候加上一个等于号

2.什么是复制构造函数,何时会用到?尤其是与赋值操作符相比,你能区分吗?
  1.根据另一个同类型的对象显示或隐式初始化一个对象.
  2.复制一个对象,将它作为实参传给一个函数(即给函数传入一个对象,会调用其复制构造函数).
  3.从函数返回一个对象时,会调用其复制构造函数.
  4.初始化顺序容器中的元素.
  5.根据元素初始化列表初始化数组元素.(class a; a arr[]={.....};):数组中的每个元素使用复制初始化来初始化每个元素,
   根据指定的值来创建适当的类型元素,然后用复制构造函数将改制复制到相应的元素
  与赋值操作符相比,对于类类型的初始化而言(复制初始化),赋值操作符总是调用复制构造函数创建一个临时的对象,然后赋值到正在创建的对象中
  复制构造函数,赋值操作符 与析构函数一般称为复制控制(Copy Control),而当一个类需要自定义复制构造函数时,一般而言我们几乎肯定也需要重载赋值操作符.
3.在C++中,何时适合通过引用来返回值,何时不适合?

4.为什么绝对不应该在析构函数中抛出异常?

  1. How many ways are there to initialize a primitive data type in C++ and what are they?
  2. Why should you declare a destructor as virtual?
  3. What does it mean that C++ supports overloading?
  4. What are examples of overloading in C++?
  5. What is name mangling in C++ and why is it used?
  6. What is an abstract base class?
  7. What is RTTI?
  8. How can you access a variable that is “hidden” by another variable of the same name?
  9. What is a namespace and how is it used.
  10. What are the differences between a class and a struct in C++, and how does this compare to C?
  11. What are templates? How are they used?
  12. What is a copy constructor and when is it used, especially in comparison to the equal operator.
  13. What is the difference between a “shallow” and a “deep” copy?
  14. What is the const operator and how is it used?
  15. What are the differences between passing by reference, passing by value, and passing by pointer in C++?
  16. When is it and when is it not a good idea to return a value by reference in C++?
  17. What is the difference between a variable created on the stack and one created on the heap?
  18. How do you free memory allocated dynamically for an array? What are the implications of just using delete?
  19. What is multiple inheritance? When should it be used?
  20. What is a pure virtual function?
  21. What does the keyword mutable do?
  22. What does the keyword volatile do?
  23. What is the STL?
  24. What is a Vector?
  25. What is contained in the <algorithms> header?
  26. What is the difference between #include <iostream.h> and #include <iostream>?
  27. What’s the difference between “++i” and “i++”?
  28. What is short circuit evaluation? How can it be used? Why can is be dangerous?
  29. What is the ‘,’ operator?
  30. What is the only ternary operator? How is it used?
  31. What is the use of a const member function and how can it be used?
  32. How is try/catch used in C++?
  33. Why should you never throw an exception in a destructor?
  34. What is the explicit keyword?
  35. What is the proper way to perform a cast in C++?
  36. What does inline do?
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值