1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;

class A{
public:
virtual void print(){
cout << "A" << endl;
}
};

class B:public A{
public:
void print(){
cout << "B" << endl;
}
};

int main(){
A b = B();
b.print(); // 这样可以吗?
return 0;
}

面试官问我这样可以吗?

我犹豫了好久好久… 也不知道可以不可以。

面试官看我答不出来,然后问我知道静态绑定和动态绑定吗?(这是在提示我了)

可我还是不知道可以还是不可以。😥

The interviewer asked me: can this be done?

I hesitated for a long, long time… and still didn’t know whether it could or couldn’t.

Seeing that I couldn’t answer, the interviewer then asked whether I knew about static binding and dynamic binding. (That was a hint to me.)

But I still didn’t know whether it could or couldn’t. 😥

C/C++Wiki笔试面经

提到 STL 算法,大家都知道很牛B。

但是想一想,除了 sort() , 你还会用啥呢?😂

最近抽时间把 STL 所有算法测试一遍,做到心里有个印象。

本文的这些示例基本上都来自于 cppreference.comcplusplus.com

其实就是挨个看一遍,然后复制粘贴一下。

STL algorithms — everyone knows they are awesome.

But think about it: apart from sort(), what else do you actually use? 😂

I recently took some time to test all STL algorithms one by one, so I have a rough idea of what each one does.

The examples in this article basically come from cppreference.com and cplusplus.com

In fact, I just went through them one by one and copy-pasted.

C/C++WikiSTL

起因

4 月 13 号早上八点多,我还在睡梦中,被 Telegram 的一条推送吵醒了。

image-20220415144506233

很奇怪,我一个根本没人访问的 WebServer 小项目竟然会自己就宕机了😕。

上午十点睡醒了,起来看一眼日志吧。

好家伙,有人拿我 抄来 的小项目在练手?

Why It Happened

Around 8 am on April 13th, I was still fast asleep when I was woken up by a push notification on Telegram.

image-20220415144506233

Strange — my little WebServer project, which nobody even visits, had crashed all by itself 😕.

I woke up again around 10 am and took a look at the logs.

Well well, someone is practicing on my copied little project?

C/C++Wiki

再分享一道笔试题

Another Written Exam Question

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;

int main(){

int a[] = {1,2,3,4,5};
int* p = (int*)(&a + 1);

cout << *(a+1) << ',' << *(p-1) << endl;

return 0;
}

问此程序的输出是多少?

错误答案是 2,1

What is the output of this program?

The wrong answer is 2,1

C/C++Wiki笔试