ykhorizon
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    C/C++ Interview Quick Notes ======== # C 語言 ## Pointer ### Pointer of variable - A variable hold the address (一個指向某個儲存位址的變數) Example: ```C int val = 10; int * prt = &val ``` 詳細可以參考 Mr. Open Gate 的文章 [C/C++ - 常見 C 語言觀念題目總整理(適合考試和面試)](http://mropengate.blogspot.com/2017/08/cc-c.html) ### Array and Pointer 的關係 在 C 語言中,處理字串一定會牽扯到 char pointer ,在基礎處理上要很注意 - https://www.geeksforgeeks.org/difference-pointer-array-c/ - https://www.geeksforgeeks.org/pointer-vs-array-in-c/ ### Function Pointer - 設計目的: - can be used to simplify code by providing a simple way to select a function to execute based on run-time values. [Function Pointer, wiki](https://en.wikipedia.org/wiki/Function_pointer) ## 變數範圍 Variable scope 和 生命週期 Variable life time - 常見有 local, static, global 被宣告為 static 的 variable 有效的生命週期是『只要在程式還在執行都可以使用』,範圍只有在宣告的區域(Ex: function) 才能被存取 詳細可以參考 [Scope and Lifetime of Variables in C](https://blog.feabhas.com/2010/09/scope-and-lifetime-of-variables-in-c/) ## Static function 效果1:當 function 前面加上 static 後,只能在同一個檔案中的 source code 使用 (即是 scope 的概念) - 類似 OOP (C++) 中的 access modifier,限制 scope 和 EX: private, protect, public ```C // source code in file1.c static int sum(int a, int b) .... // source code in file2.c sum(10,5) // compiler error ``` 效果2:不同檔案中,被宣告為 static 的 function,因為 scope 只有在該檔案,所以可以在不同檔案中重複使用該 function 的名字,compiler 會認為是不同的 function (會有一點confused要小心一點) ```C // source code in file1.c static int sum(int a, int b) .... // source code in file2.c static int sum(int a, int b) .... sum(10,5) // compiler error ``` [Detail: Static functions in C](https://www.geeksforgeeks.org/what-are-static-functions-in-c/) 解釋:[link1](https://softwareengineering.stackexchange.com/questions/250126/static-vs-non-static-with-non-oop-functions) ## Declaration and Definition 差別 ## 記憶體配置 Memory allocation 請參考 Mr. Open Gate 的文章 [C/C++ - 常見 C 語言觀念題目總整理(適合考試和面試)] 的 [用心去感覺] 記憶體的配置 ## Struct Memory with Compiler Optimization <iframe src="//www.slideshare.net/slideshow/embed_code/key/gDVgIO0rg38cDQ?startSlide=203" width="595" height="485" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe> <div style="margin-bottom:5px"> <strong> <a href="//www.slideshare.net/olvemaudal/deep-c" title="Deep C" target="_blank">Deep C</a> </strong> from <strong><a href="//www.slideshare.net/olvemaudal" target="_blank">Olve Maudal</a></strong> </div> ## Source code 如何被 compile 成執行檔 可以參考一下投影片『How A Compiler Works: GNU Toolchain』,至少有概念就好(p9~p14) <iframe src="//www.slideshare.net/slideshow/embed_code/key/pIAwbkbnVdXxBY" width="595" height="485" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe> <div style="margin-bottom:5px"> <strong> <a href="//www.slideshare.net/jserv/how-a-compiler-works-gnu-toolchain" title="How A Compiler Works: GNU Toolchain" target="_blank">How A Compiler Works: GNU Toolchain</a> </strong> from <strong><a href="https://www.slideshare.net/jserv" target="_blank">Jim Huang</a></strong> </div> # C++ Object-Oriented Programming ## Encapsulation Access modifier - public - private - protect: can be access by derived class ## Inheritance ## Polymorphism - virtual function [Commonly Asked OOP Interview Questions | Set 1](https://www.geeksforgeeks.org/commonly-asked-oop-interview-questions/) # Problems normal swap swap without temp review linked-list static function difference of tcp and udp 3-way handshape DHCP grep code review implement strcpy topology subnet mask (16 server) assign value to char* char[] strlen(*ptr) ok # Main References - Interview Problems - [C/C++ - 常見 C 語言觀念題目總整理(適合考試和面試)](http://mropengate.blogspot.com/2017/08/cc-c.html) - https://www.geeksforgeeks.org/commonly-asked-c-programming-interview-questions-set-1/ - https://www.geeksforgeeks.org/commonly-asked-c-programming-interview-questions-set-2/ - Reading Material - [Deep C (and C++), 強烈推薦](https://www.slideshare.net/olvemaudal/deep-c) - Tutorial Material - https://www.learn-c.org/ - https://beginnersbook.com/2014/01/c-tutorial-for-beginners-with-examples/

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully