因为要离开现公司, 两个月前招到一个来接替我的小伙子, 此子只用过 C, 做了半年嵌入式, 我对他进行了两个月的 C++培训, 带着他看 C++ primer 这本书(这本书既厚又杂,想着有我帮着梳理的话亦可事半功倍, 感觉这本书不太好, 但是又没找到可替代的又是中文版的 C++入门书), 让他完成一些编程任务, 帮他 debug 并解惑, 更多的是解释原理: 为什么是这样的.
现在到考核期了, 公司要求用英文出题考核他, 题如下:
(3 points each, 15 points total)
Which one of the following C++ codes is correct C++11 expression?
const int i{3.14}
;int & i = 233
;const int& i{3.14};
constexpr double pi{3.14};
which one of the following is valid lambda expression usage?
[ ] A.
int i = 10;
auto f = [](){ return i+1;};
f();
[ ] B.
int i = 10;
auto f = [](int i){ return i+1;};
f();
[ ] C.
int i = 10;
auto f = []{ return i+1;};
f();
[ ] D.
int i = 10;
auto f = [i]{ return i+1;};
f();
What does public inheritance mean?
What does private inheritance mean?
[ ] A. Implementation details
[ ] B. Private interfaces
[ ] C. Composition
[ ] D. Is-a relationship
Suppose we have two classes(both with default constructors): class Base{...};
, class Derived: public Base {...};
, which one of the following usage is correct?
Derived* d = new Base;
Derived* d = new Base{};
std::unique_ptr<Base> ptr = std::make_unique<Derived>();
std::unique_ptr<Derived> ptr = std::unique_ptr<Derived>(new Base);
(5 points each, 25 points total)
Use range for
syntax to add 10 to each elements of the following vector
:
auto numbers = std::vector<int>{1, 2, 3, 4, 5};
Use std::for_each
to answer the previous question.
Suppose Buffer* create_buffer()
is some library function to allocate resources, and bool release_buffer(Buffer* buffer)
is the counterpart to free the allocated resources, use std::unique_ptr
to manage the resources.(hint: when the std::unique_ptr
object is out of scope, the allocated resources are automatically released.)
Suppose class Object
must have a copy constructor, a copy assign operator, a move constructor, a move assign operator and a destructor, write down their signatures .
RAII is a key C++ programming technique, write down your understanding of RAII (not the literal meaning)
我参考当初他问过的问题以及给他的解答出的, 当然考核只是个形式, 所以我直接把题给他先看看, 让他先尝试着做, 结果一题不会! 苦口婆心两个月 == 0.
有一些想法:
考核肯定是过不了的了, 最后估计会留在公司打杂, 因为最近又招了个新的人, 还没来报道, 看简历是个硕士, 虽然没写过 C++, 但会 python 跟 java, 在学校也搞过正儿八经的研究. 这个带起来应该能很快起飞, 但已经等不到了, 今天是在该公司的最后一天, 只能祝福着这位"带不动同事", 平静地离开了.
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.