32 Matching Annotations
  1. Apr 2022
    1. By default, C++ will provide a copy constructor and copy assignment operator if one is not explicitly provided. These compiler-provided functions do shallow copies, which may cause problems for classes that allocate dynamic memory. So classes that deal with dynamic memory should override these functions to do deep copies.

      c++ 默认提供什么样的 copy constructor,这会导致什么问题?

  2. Mar 2022
    1. Move semantics means the class will transfer ownership of the object rather than making a copy.

      move semantics 是什么意思?

    2. A Smart pointer is a composition class that is designed to manage dynamically allocated memory and ensure that memory gets deleted when the smart pointer object goes out of scope.

      smart pointer 是什么?有什么好处?

    1. ● Global symbols○ Symbols defined by module m that can be referenced by other modules.■ e.g., non-static C functions and non-static global variables.● External symbols○ Global symbols that are referenced by module m but defined by some other module.● Local symbols○ Symbols that are defined and referenced exclusively by module m.■ e.g., C functions and global variables defined with the static attribute.○ Local linker symbols are not local program variables

      分别有哪些 linker symbol?

    2. ● Symbol resolution○ Programs define and reference symbols (global variables and functions)○ Linker associates each symbol reference with exactly 1 symbol definition● Relocation○ Merges separate code and data sections into single sections○ Relocates symbols from relative locations in .o files to final memory locations○ Updates all references to symbols to reflect new positions

      linker 到底做了什么?

    3. ● Aggregates multiple independently compiled files containing machine code● Fills in those unknown addresses● The goal is to create 1 file with all of the needed code to run the program

      linker 的流程是什么?

    4. ○ This changes the format and structure of the code but preserves the semantics (what it does)○ Can change lots of details for optimization, as long as the overall effect is the same

      compiler 部分的流程是什么?

    5. ● Processes #include, #define, #if, macros○ Combines main source file with headers (textually)○ Defines and expands macros (token-based shorthand)○ Conditionally removes parts of the code (e.g. specialize for Linux, Mac, ...)● Removes all comments

      Pre-Processor 部分的流程是什么?

    6. Four steps for C: preprocessing, compiling, assembling, linking

      compile code 有哪 4 步?

  3. Feb 2022
    1. Online C++ Compiler

      InterviewBit provides us with one of the best C++ compilers that is easily operated and that supports multiple programming languages.

  4. Jan 2022
  5. Nov 2021
    1. asm.js subset is basically JavaScript where you can only use numbers (no strings, objects, etc.). This is all you need to run C++ code since everything in C++ is either a number or a pointer to a number, and pointers are also numbers. The C++ address space is just a giant JavaScript array of numbers and pointers are just indices into that array.

      everything in C++ is either a number or a pointer to a number, and pointers are also numbers.

    2. Because our product is written in C++, which can easily be compiled into WebAssembly, Figma is a perfect demonstration of this new format’s power.

      Figma is written in C++, which can easily be compiled into WebAssembly

    1. A namespace is a scope.C++ provides namespaces to prevent name conflicts.

      namespace 有什么作用?

    1. But the other effect of unnamed namespaces is that all identifiers inside an unnamed namespace are treated as if they had internal linkage, which means that the content of an unnamed namespace can’t be seen outside of the file in which the unnamed namespace is defined.

      unnamed namespace 有什么作用?

    1. One of the best things about classes is that they contain destructors that automatically get executed when an object of the class goes out of scope. So if you allocate (or acquire) memory in your constructor, you can deallocate it in your destructor, and be guaranteed that the memory will be deallocated when the class object is destroyed (regardless of whether it goes out of scope, gets explicitly deleted, etc…).

      smart pointer 的原理是什么?

  6. Apr 2020
    1. Sedation, osmotic diuresis, paralysis, ventricular drainage, and barbiturate coma are used in sequence, with coma induction being the last resort.
    2. Cerebral perfusion pressure (CPP) is equal to the mean arterial pressure minus the ICP, with a target range of >60 mmHg.
    3. CPP can be increased by either lowering ICP or raising mean arterial pressure.
  7. May 2017
    1. If you succeeded in not throwing exceptions from your overloads, then make sure to advertise that fact using the new noexcept keyword.

      好的习惯

    1. Base(rhs) // wrong: rhs is an lvalue

      这里要记住,很容易犯错,关键还是理解 it has a name rule

  8. Dec 2016
    1. RAII-style

      对象构建时创建资源,区别于MFC那种显示调用init

  9. Aug 2016
    1. return reinterpret_cast<T *>(& const_cast<char&>(reinterpret_cast<const volatile char &>(v)))

      核心思想是转化为char, 然后取地址

  10. Jun 2016