Giter Site home page Giter Site logo

huihut / interview Goto Github PK

View Code? Open in Web Editor NEW
33.3K 33.3K 7.9K 5.24 MB

📚 C/C++ 技术面试基础知识总结,包括语言、程序库、数据结构、算法、系统、网络、链接装载库等知识及面试经验、招聘、内推等信息。This repository is a summary of the basic knowledge of recruiting job seekers and beginners in the direction of C/C++ technology, including language, program library, data structure, algorithm, system, network, link loading library, interview experience, recruitment, recommendation, etc.

Home Page: https://interview.huihut.com

License: Other

C 8.50% C++ 90.30% CMake 1.20%
algorithm c cpp data-structures database interview interview-practice interview-preparation interview-questions interviews leetcode operating-system stl

interview's Issues

this指针的一个表述问题

this指针第一行,“它指向正在被该成员函数操作的那个对象。”描述不恰当。建议改成“它指向调用该成员函数的那个对象”。

C/C++ 智能指针中,unique_ptr小节有错别字(粗体处)

unique_ptr 是 C++11 才开始提供的类型,是一种在异常时可以帮助避免资源泄漏的智能指针。采用独占式拥有,意味着可以确保一个对象和其相应的资源同一时间只被一个 pointer 拥有。一旦拥有被销毁或编程 empty,或开始拥有另一个对象,先前拥有的那个对象就会被销毁,其任何相应资源亦会被释放。

可能不准确的地方

翻到了这个指导,光看了readme的前几个部分就感觉十分有收获(到网络IO部分为止)。但是在看的同时对不熟悉的东西做了一下调查,觉得有下面几个地方可能可以优化一下?

  1. inline 函数似乎原则上可以含有复杂一些的,如循环的操作,尽管可能编译器并不会内联。参考的是在stackoverflow的讨论

  2. 并不是所有时候都是尽量使用const比较好。在返回值(非引用)的时候,const 返回值目前大部分情况下并不是一个很好的选择。参考的是stackoverflow的另一个讨论,和这个讨论指向的另一个

总之,非常感谢总结!

stl的lower_bound和upper_bound的函数功能解释有点问题。

lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个非递减序列[first, last)中的第一个大于等于值val的位置。
upper_bound(ForwardIter first, ForwardIter last, const _Tp& val)算法返回一个非递减序列[first, last)中第一个大于val的位置。
default

好东西啊

最近想学习c++,老哥这个写的很实用

线程安全

面试的时候,有人问我线程安全方面的知识,
这里面是不是也得补充一下 啊, 大佬

链接挂了

C 语言实现封装、继承和多态 这个链接挂了

关于内联函数特征的描述

类中除了虚函数的其他函数都会自动隐式地当成内联函数。

应该是
在类声明中定义的函数,除了虚函数之外的其他函数都会自动隐式地当成内联函数。

平衡二叉树的概念

平衡二叉树这里

平衡二叉树必定是二叉搜索树,反之则不一定

平衡二叉树一定是二叉搜索树吗?不是二叉搜索树的树也能平衡的吧?

使用更广为接受的方式介绍 explicit 关键字

首先感谢 Repo 主维护这么棒的 Repo,好多同学都向我推荐了这个。在阅读过程中,我发现对 explicit 关键字的介绍可以做得更好一些。

之前介绍到「explicit 修饰的构造函数可用来防止隐式转换」,而在 cppreference 中介绍到 「指定构造函数或转换函数 (C++11 起)为显式,即它不能用于隐式转换和复制初始化。」。这个表述更好一些,因为 1)这是官方的翻译,接受范围更广;2)区分了用于构造函数和转换函数两种使用场景,而且区分了隐式转换和复制初始化两种编译器行为,更为严谨。

但这样说显然很僵硬,因此可以这样优化:「explicit 修饰构造函数时可防止复制初始化;修饰转换函数(C++11 起)时可防止隐式转换」。

然而这句话的后半句是有问题的,因为存在名为「按语境转换」的例外,这样的例外使得在 if 等需要隐式将右值转换为 bool 的场景下,即使转换函数被声明为 explicit 的,隐式转换仍会发生。考虑到 repo 主的风格是不喜欢放太多细节的东西,这句话可以这样说:「explicit 修饰构造函数时可防止复制初始化;修饰转换函数(C++11 起)时可防止部分隐式转换」。

另外示例部分也可以做相应调整,从而和上文表述相一致。直接从 cppreference 中拿过来是最简单的做法。至于放不放上述特例,则取决于你的偏好了。

图挂了

数据结构中

  1. 双向链表图片
    image

TCP释放连接过程

文本错误
6. 客户端收到服务端的 FIN+ACK,并回复 ACK 给客户端(同意释放从服务端到客户端的连接)

[discuss] inaccurate description

Quote
Reference to const
There is no const reference because the reference itself is a const pointer

reference is NOT an object, that's the reason why NO reference itself is const.

Is it a typo?

The following is taken from https://interview.huihut.com/#/en?id=const.

class A
{
private:
    const int a;                // constant object member, can only be assigned in the initialization list

public:
    // Constructor
    A() : a(0) { };
    A(int x) : a(x) { };        //  initialize list

   // others are removed for the sake of simplicity 

};

void function()
{
    // object
    A b;                        // ordinary object, can call all member functions, update constant member variables
     
   // others are removed for the sake of simplicity 
}

ordinary object, can call all member functions, update constant member variables

I think constant members cannot be updated. Is it a typo?

关于STL内存分配器的描述

小于 128Bytes 使用一个 8Bytes 倍数的数组来进行申请(原因是为了提高效率,同时对于 64 位的机器而言,地址大小为 8Bytes)

不知道你是不是看的侯捷的书,那本书太老了。你可以看下较新版的C++实现,直接调用的new delete

初始化列表问题

看到您说没有默认构造函数的类类型,因为使用初始化列表可以不必调用默认构造函数来初始化,而是直接调用拷贝构造函数初始化

我认为:如果使用“初始化列表”对“没有默认构造函数的”的类成员进行初始化,应该也是调用了其“含参构造函数”吧?

大小写问题

derived(parms) : base(args) { }
这里应该改为大写?

勘误

C/C++ 面试知识总结下
数据结构栏目中
二叉树性质解释中第5条第二点是2i

gitbook插件问题

您好,想问下您用的是什么插件,可以根据markdown的标题,自动在侧边栏生成目录

[outreachy/gsoc] Interested in contributing

I'm Vishnupriya Srivastava, from India.I am completing my graduation from Bits Pilani,India.I am a backend developer.I've done projects for my college using django framework,recently i worked with django channels creating a multichat gaming website.I know c and python and recently learning docker.
I would like to contribute to your project either by participating in outreachy or gsoc.
I read about this projects from last year's .

Please guide to on getting started.

C++小白请教问题。

// 因为Base有虚析构函数(virtual ~Base() {}),所以 delete 时,会先调用派生类(Derived)析构函数,再调用基类(Base)析构函数,防止内存泄漏。
delete ptr;
ptr = nullptr;

对于这里不是很理解。意思是实际调用的是delete ptr; 内部却自动析构了2个对象?

经过实验发现可以取得this的地址

感谢这份教程,写的很详尽。

this指针那一节中说,“由于 this 并不是一个常规变量,所以,不能取得 this 的地址”。写了一个测试程序,发现可以取得this的值,如有错误还请指正。

#include <iostream>

class Foo
{
  public:
  void print_foo()
  {
    std::cout << this << std::endl;
  }
};

int main()
{

  Foo obj;
  obj.print_foo();
  return 0;
}

[讨论] 本仓库的建议、讨论等方面

这个仓库原本只是我的个人笔记,鉴于越来越多人关注,而本人技术略渣,希望大家可以提些建议,或者可以在这个 issue 讨论些关于面试方面的东西。比如:

  • 需要增加什么知识点?
  • 如何分类排版才更高效地复习与检索?
  • 如何勘误,发现错误如何改正?(new issue、pull)
  • 如何提交或添加你的知识点、总结、面经?(new issue)
  • 等等

(本 issue 只涉及讨论、建议、疑问等方面,内容勘误、提交贡献还请新建一个 issue 或 pull)

English Version

Is English Version available? If not may I translate this repository/site? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.