新同事的考核, 一题也不会

2019-07-18 13:22:16 +08:00
 justou

因为要离开现公司, 两个月前招到一个来接替我的小伙子, 此子只用过 C, 做了半年嵌入式, 我对他进行了两个月的 C++培训, 带着他看 C++ primer 这本书(这本书既厚又杂,想着有我帮着梳理的话亦可事半功倍, 感觉这本书不太好, 但是又没找到可替代的又是中文版的 C++入门书), 让他完成一些编程任务, 帮他 debug 并解惑, 更多的是解释原理: 为什么是这样的.

现在到考核期了, 公司要求用英文出题考核他, 题如下:

C++ Questions

Single Choice

(3 points each, 15 points total)

  1. Which one of the following C++ codes is correct C++11 expression?

    • [ ] A. const int i{3.14};
    • [ ] B. int & i = 233;
    • [ ] C. const int& i{3.14};
    • [ ] D. constexpr double pi{3.14};
  2. 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();
      
  3. What does public inheritance mean?

    • [ ] A. Implementation details
    • [ ] B. Private interfaces
    • [ ] C. Composition
    • [ ] D. Is-a relationship
  4. What does private inheritance mean?

    • [ ] A. Implementation details

    • [ ] B. Private interfaces

    • [ ] C. Composition

    • [ ] D. Is-a relationship

  5. Suppose we have two classes(both with default constructors): class Base{...};, class Derived: public Base {...};, which one of the following usage is correct?

    • [ ] A. Derived* d = new Base;
    • [ ] B. Derived* d = new Base{};
    • [ ] C. std::unique_ptr<Base> ptr = std::make_unique<Derived>();
    • [ ] D. std::unique_ptr<Derived> ptr = std::unique_ptr<Derived>(new Base);

Answer the following questions

(5 points each, 25 points total)

  1. Use range for syntax to add 10 to each elements of the following vector:

    auto numbers = std::vector<int>{1, 2, 3, 4, 5};

    
    
  2. Use std::for_each to answer the previous question.

    
    
  3. 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.)

    
    
  4. 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 .

    
    
  5. RAII is a key C++ programming technique, write down your understanding of RAII (not the literal meaning)

    
    

我参考当初他问过的问题以及给他的解答出的, 当然考核只是个形式, 所以我直接把题给他先看看, 让他先尝试着做, 结果一题不会! 苦口婆心两个月 == 0.

有一些想法:

  1. 想 21 天精通 C++, 得参考某张漫画里面来, 一时找不到图了, 就是最后发明时光机穿越回到学 C++第 21 天, 然后捅死自己那张漫画;
  2. 新同事学习方法很有问题, 每次我跟他讲一些原理的时候让他记一下, 他说这个很显然啊, 没必要记, 然后下次问他相同问题, 对方回答无非是"搞忘了", "你跟我讲过这个吗?" ,根本带不动!
  3. 不梳理知识, 只在书里面随便勾勾画画, 当然这本书等于没看;
  4. 题可能出得太难了, 不适合 C++初学者, 但是平时这些主题讲得特别多, 现在看来对方的"嗯嗯, 理解了"明显是在敷衍我了, 其实那根本是在敷衍自己;
  5. 英文太差, 其实一开始题都没读懂, 我一个个地解释了一遍, 还是不会做;
  6. 搜索引擎对他来讲是摆设.
  7. 人不笨, 但是思维方式已经出现严重问题了, 想甩锅给他之前受过的应试教育. 平时给他讲了很多学习方法跟思考方式, 估计也早成耳边风了.

考核肯定是过不了的了, 最后估计会留在公司打杂, 因为最近又招了个新的人, 还没来报道, 看简历是个硕士, 虽然没写过 C++, 但会 python 跟 java, 在学校也搞过正儿八经的研究. 这个带起来应该能很快起飞, 但已经等不到了, 今天是在该公司的最后一天, 只能祝福着这位"带不动同事", 平静地离开了.

20038 次点击
所在节点    程序员
173 条回复
lucifer9
2019-07-18 14:07:18 +08:00
为啥要招个只用过 C 完全没 C++ 经验的呢
a566
2019-07-18 14:09:37 +08:00
好人啊 我怎么遇见不到啊
bzshow1
2019-07-18 14:14:30 +08:00
楼主招我吧
Otho
2019-07-18 14:14:41 +08:00
太依赖了
bayker
2019-07-18 14:20:37 +08:00
楼主在哪,能拜你为师吗,真心的
pyscream
2019-07-18 14:21:39 +08:00
所以能贴个答案吗,感觉自己也答不上几道
justou
2019-07-18 14:23:49 +08:00
@lucifer9 招不到人, 来面试的都是些基本符合需求的, 然后从里面选可培养性稍微强一点的

@a566
@fy1993
@janus77 只要是愿意学习想学习的, 不管他多菜, 我都愿意带, 愿意跟他分享我的理解, 我发现当自己用某些方式把一个不懂的人讲得真正懂的时候自己也会在这个点上有更深的理解
justou
2019-07-18 14:25:37 +08:00
我看这个同事每天看书挺带劲儿的, 以为他在很认真的看, 或许是真的在很认真的看, 但是知识吸收率太低了
poplar50
2019-07-18 14:25:47 +08:00
楼主好人 两个月时间培训相比我们公司要求你啥都得飞速上手真的羡慕了
justou
2019-07-18 14:29:13 +08:00
@bayker 即将离开重庆去深圳, 拜师不敢当, 我觉得多提问题就好, 放到网上合适的地方去, 自有"好为人师"的人来解答,
@pyscream 稍后写上参考答案
chaffy
2019-07-18 14:33:48 +08:00
这么好楼主哪里找
silverbooker
2019-07-18 14:35:54 +08:00
一题都不会可还行……菜的真实。
Earl
2019-07-18 14:36:31 +08:00
lz 好人。
如果闭卷的话,我觉得一个才接触 c++两个月的,这些题目的确不一定能做出来。主要很多东西意思明白,但是正确的语法可能记不全。
如果开卷的话,这些题目就不算难了。
perfectlaugh
2019-07-18 14:37:29 +08:00
试试看解答 要不然我的 C++都要生锈了
1. D
2. A
3. D
4. C
5. C

1.
```
for (auto& number: numbers) {
number += 10;
}
```
2.
```
std::for_each(numbers.begin(), numbers.end(), [](auto& number) { number += 10; });
```
3.
```
class Object {
Buffer* _buf;
public:
Object() {
_buf = create_buffer();
}
~Object() {
release_buffer(_buf);
}
// It is better to use operator* though... Just in case
Buffer* get_buf() {
return _buf;
}
}

// std::make_unique<Object>();
```
4.
```
class Object {
//copy constructor
Object(const Object& _other) {
}
//move constructor
Object(Object&& _other) {
}
//copy assignment operator
operator=(const Object& _other) {
}
//move assignment operator
operator=(Object&& _other) {
}
//destructor
~Object() {
}
}
```
5.
Resource Acquisition Is Initialization
Using OOP constructor and destructor to let resource allocate and deallocate properly. (?)
EthanDon
2019-07-18 14:38:43 +08:00
@justou 5555 复读过的人真心深有体会,学习方式、思维方式真的占了成绩大头!良好的学习方式和思维方式加上努力是个人都能上重本,稍微聪明一点再努力一点的都能上 211 了!

复读的时候到了某个高考工厂,老师教了一套学习方法,自己又悟出来一点,成绩可谓突飞猛进!现在每每看到有人写方法论都会搜藏下来,平时自己也喜欢总结一下方法。
perfectlaugh
2019-07-18 14:38:46 +08:00
哎 上面的 operator 忘了 void...
zcjfesky
2019-07-18 14:39:23 +08:00
@yueqiuge 常见的说法是 multiple answer question
Yourshell
2019-07-18 14:39:36 +08:00
一题都不会,没学过 cpp
ooee2016
2019-07-18 14:43:57 +08:00
公司真抠
sangleft
2019-07-18 14:44:08 +08:00
一题都不会是过分了。

两个月啃了十章多 primer,还是有不会的题,把书读薄确实不容易啊。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/584098

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX