二進制字面量 C++14 引入了二進制字面量(binary literals),這使得在程式碼中直接表示二進制數字變得更加容易和直觀。 這對於需要使用二進制表示的位操作或位掩碼的情況非常有用。 也就是直接在數值上面加上 0B or 0b 幫助其他人了解這邊使用二進制數字,這樣就不用自己用計算機重新轉成二進制。 直接看 code // 輸出整數值的二進制表示 template <...
Item 11 - 二進制字面量(binary literals) (中文)
Item 11 - binary literals (English)
Binary Literals C++14 introduced binary literals, making it easier and more intuitive to represent binary numbers directly in code. This is particularly useful for situations requiring bitwise op...
Item 10 - static_assert (中文)
static_assert static_assert 是 C++11 中的一個關鍵字,用於在編譯時進行斷言檢查,如果條件不滿足,則將在編譯時產生錯誤。 這對於檢查程式碼的靜態不變條件或斷言非常有用, 特別是 tempalte 相關的 function. 主要精神 可以 compile 時檢查出來問題,盡量在 compile 時被檢查出來。這種問題修復所需的時間最少。 進入 runti...
Item 10 - static_assert (English)
static_assert static_assert is a keyword introduced in C++11 for performing assertion checks at compile-time. If the condition is not satisfied, it generates an error during compilation. This is p...
Item 9 - constexpr (English)
The constexpr Keyword C++11 introduced the constexpr keyword, which is used to declare functions or variables that can be evaluated at compile time. Functions or variables marked as constexpr can ...
Item 9 - constexpr (中文)
constexpr 關鍵字 C++11 引入了 constexpr 關鍵字,用於宣告可以在編譯時求值的函數或變數。 這樣的函數或變數可以在編譯時被求值,而不是在運行時,從而提高了程式的性能和效率。 constexpr 的使用時機通常是在需要在編譯時計算值的情況下,例如在模板元編程中、在宣告常數表達式時等。 簡單的來說,就是把執行時計算的時間移到 complie 時。 這麼好要不要全部 ...
C++ 引用防護(中文)
C++ 引用防護(Include Guard) 你在看 C++ 的 code 時,header 部分常常會看到下面這種 code #ifndef MYHEADER_H #define MYHEADER_H // 在這裡放置頭文件的內容 #endif // MYHEADER_H 這倒底在幹嘛?跟條件編譯有關嗎? 真心覺得 C++ 很難學的原因之一就是太多細節,很容易搞混。 光是 r...
C++ Include Guard(English)
C++ Include Guard When you’re looking at C++ code, you often come across code like this in the header part #ifndef MYHEADER_H #define MYHEADER_H // Contents of the header file go here #endif // ...
sitemap Introduction 2(English)
Submitting Sitemap Using Google Search Console 1.Go to the website https://search.google.com/search-console/welcome . 2.You’ll see two options: “Domain” and “URL prefix.” The “Domain” option integr...
sitemap Introduction(English)
Sitemap Explanation A “Sitemap” is a file used to provide information about a website, where you can list details of web pages, videos, and other files, presenting the relationships between these c...
隱私權政策
隱私權政策 隱私權政策 非常歡迎您光臨「JE Sharing」(以下簡稱本網站),為了讓您能夠安心的使用本網站的各項服務與資訊,特此向您說明本網站的隱私權保護政策,以保障您的權益,請您詳閱下列內容: 一、隱私權保護政策的適用範圍 隱私權保護政策內容,包括本網站如何處理在您使用網站服務時收集到的個人識別資料。隱私權保護政策不適用於本網站以外的相關連結網站,也不適用於非本網站所委託或參與管理...
DLL 顯示連結 Explicit Linking (中文)
只需要 .dll and header 建立使用 DLL 的專案 這次我們的專案屬性不需要額外設定, 只要確保 .dll 和我們的 .exe 放在同一層 而且我們可以 include 到對應 header 就好。 但是需要以下步驟 包含頭文件:需要包含 DLL 中定義的頭文件,以便你的程式知道 DLL 中提供的函式、結構或類的定義。 載入 DLL:在程式碼中使用 LoadL...
DLL Explicit Linking(English)
We only need .dll and header Creating a Project Using a DLL This time, our project properties don’t need any additional settings. Just make sure the .dll and our .exe are placed in the same direc...
DLL 隱式連結(Implicit Linking)(中文)
需要 .lib .dll and header DLL 專案設定: DLL 真的是好用,但是設定很繁瑣,也很容易出錯。 以下的例子會示範 export dll function export dll struct export dll class export dll template function 應該很完整(有誠意)了吧 建立 DLL 專案...
DLL Implicit Linking(English)
We need .lib .dll and header Setting Up a DLL Project: Creating a DLL project can indeed be useful, but the setup process can be tedious and error-prone. The following example demonstrates ...
Item 6 - nullptr (中文)
空指針常量(nullptr) 不要在讓 pointer 去判斷是否等於 0 or NULL 了!!! 在 C++11 中引入了空指針常量 nullptr,它可以用來代替傳統的 NULL 或 0,以提高程式碼的清晰度和安全性。 以下是一個簡單的範例 直接看 code #include <iostream> void foo(int* ptr) { if (ptr...
Item 6 - nullptr (English)
Null Pointer Constant (nullptr) Stop using pointers to check whether they’re equal to 0 or NULL!!! In C++11, the nullptr null pointer constant was introduced, which can be used instead of the tra...
介紹 DLL (Dynamic Link Library)(2/2)(中文)
主要兩種使用方式 有顯式連結(Explicit Linking)和隱式連結(Implicit Linking),後續 都會有實際的範例一步一步示範。 現在主要介紹這兩種方式主要的不同,這樣才不會在後續的實作搞混。 顯式連結(Explicit Linking) 在程式執行期間,使用函式庫的函式前需要明確地載入 DLL 並獲取函式指標。 主要步驟包括載入 DLL、獲取函式指標、調...
DLL(Dynamic Link Library) (2/2)Introduction(Engish)
The main two usage methods The main two usage methods are Explicit Linking and Implicit Linking. Let’s look at their main differences so that we don’t get confused in subsequent implementations. ...
DLL(Dynamic Link Library) (1/2)Introduction(Engish)
What is a DLL? When you develop software on Windows or simply browse through folders on a Windows system, you often come across files with the .dll extension. Moreover, senior members in your team...
介紹 DLL (Dynamic Link Library)(1/2)(中文)
DLL 到底是啥 ? 當你在 Windows 上開發程式,或是在 Windows 上面隨便瀏覽系統的資料夾,一定常常看到 .dll 的檔案, 還有團隊內的長輩常常說 “把 XXX 功能包成 dll” 給其他模組使用..etc 講得很神,Dll 到底是啥? DLL (Dynamic Link Library) 是一種在微軟 Windows 作業系統中常見的檔案格式。它是一種可重複使用的程...
C++ 的條件編譯(中文)
C++ 的條件編譯 你在看 C++ 的 code 時,特別是大項目的 code,一定會看到 #ifdef or #ifndef …etc, 很多這樣的程式片段,有的在 IDE 上顯示正常,有的比較灰, 這到底是在幹嘛的?重要嗎? 非常重要 !!! 沒有注意到的話,很有可能你辛辛苦苦修改的 code,但其實在 不正確的組態下修改,導致根本跟沒有修改一樣,bug 同樣存在,被客戶念,被 QA ...
Conditional Compilation in C++(English)
Conditional Compilation in C++ When you’re looking at C++ code, especially in large projects, you’ll often see #ifdef or #ifndef…etc. Many such code snippets display normally in the IDE, while oth...
Docker 介紹與基本指令 (II)(中文)
當你使用 Docker 建構和執行容器時,一定會使用 docker build 和 docker run 指令。 以下是這兩個指令的基本用法(學會就可以說嘴自己會使用 Docker 了) Docker Build 指令 使用 docker build 指令可以從 Dockerfile 建立一個 Docker 映像(image)。 以下是基本的指令格式 docker build -t...
Introduction to Docker and Basic Commands (II)(English)
When you’re building and running containers with Docker, you’ll definitely use the docker build and docker run commands. Here are the basic usages of these two commands (Once you’ve learned these,...
使用 VS Code + docker 快速建立開發環境(中文)
建立開發環境 上一篇已經把 Docker 的好處說了一遍,特別在部屬的階段,更是相當方便。 但是,開發呢? 沒有開發完成的服務,如何談得上部屬呢? 試過很多種 IDE 對 Docker 的整合,目前覺得 VS Code 的整合非常棒,最棒的是 VS Code is free. 目前 VS Code 版本(因為 VS Code 版本更新後,建立開發環境的步驟有點不同, 所以發一篇教學分享)...
Using VS Code + Docker to quickly set up a development environment(English)
Establishing a development environment Establishing a development environment In the previous post, we talked about the benefits of Docker, especially during the deployment phase, which is extreme...
Item 4 (2/2)- unordered_map (中文)
c++ 新的容器類型: unordered_map C# 有 Dictionary 可以用,python 也有這種 key value mapping 的資料結構可以使用。 C++ 呢 ? C++ 11 提供 unordered_map 供 coder 使用。unordered_map 之所以被稱為 unordered ,是因為它是基於哈希表(hash table)實現的,而哈希表不保證元...
Item 4 (2/2) - unordered_map (English)
c++ New Container Type: unordered_map In C#, you have Dictionary, and Python also offers similar key-value mapping data structures to use. How about C++? Well, C++11 provides unordered_map for cod...
Item 4 (1/2) - array of std(中文)
c++ 新的容器類型: array 覺得 c++ 的 array 太難用 ? 像是 int[5] , 沒提供什麼成員函數來協助 coder, 沒關係,可以使用 std::array. 當需要一個固定大小的陣列,並且知道其大小時,可以使用 c++11 std::array。它比內置的陣列更加安全和方便,因為它提供了陣列的大小信息和一些方便的成員函數。 直接看 code #inclu...