原创 關於std::lower_bound和st::upper_bound

std::lower_bound和st::upper_bound詳細使用說明請看代碼 // #include <iostream> #include <cstdlib> #include <vector> #include <a

原创 使用 git clone命令 下載特定tag

git clone --branch [tags標籤] [git地址]

原创 c++ 如何合併兩個vector

//by 鳥哥 合併vector的方法 //有疑問請留言或加羣 1032082534 #include <iostream> #include <vector> #include <algorithm> #include <fun

原创 c++ 圓整(取整)相關函數大全(rint lrint llrint round ceil floor trunc)

1、圓整方向模式: 宏 描述 FE_DOWNWARD Round downward.(向下取整) FE_TONEAREST Round to nearest.(向最近取整) FE_TOWARDZERO Rou

原创 c++ vector拷貝方法總結

//by 鳥哥 vector 拷貝的三種方式 //有疑問請留言或加羣 1032082534 #include<iostream> #include<vector> using namespace std; void printVe

原创 protobuf(c++)設置嵌套類的值的兩種方法(set_allocated_和mutable_的使用)

.proto 文件如下: syntax = "proto3"; package geomproto; message Geom{ Point2d p=1; } message Point2d{ doubl

原创 利用c++random庫產生 0到1之間的隨機實數

//產生非確定性隨機數(多次次運行時每次產生的隨機數不一樣) #include <iostream> #include <random> int main() { std::random_device e;

原创 c++容器返回最後一個元素的四種方法

//by 鳥哥 獲取容器的最後一個元素 //有疑問請留言或加羣 1032082534 #include <iostream> #include <vector> using namespace std; int main(){

原创 vc中類靜態成員變量引起的鏈接錯誤: error LNK2001: 無法解析的外部符號

1、錯誤代碼 main.cpp #include <iostream> #include "a.h" using namespace std; int main() { a::x=0; cout<<a::x<<e

原创 windows下載編譯cef

0、確保系統已經安裝vs 2017或2019 1、下載CEF,地址 http://opensource.spotify.com/cefbuilds/index.html 2、解壓下載的安裝包。 3、運行CMake_GUI.exe。

原创 c++ 中的 參數依賴查找(argument-dependent lookup 簡稱 ADL)

//by 鳥哥 演示 參數依賴查找 //有疑問請留言或加羣 1032082534 #include <iostream> using namespace std; namespace test{ class T{};

原创 c++ shared_ptr 按引用傳參不增加引用計數

//by 鳥哥 演示 shared_ptr 不增加引用計數的情況 //有疑問請留言或加羣 1032082534 #include <iostream> #include <memory> using namespace std;

原创 函數模板引起的 LNK2005錯誤(gcc錯誤提示是 multiple definition)

1、錯誤代碼 a.h #ifndef a_h #define a_h #include <iostream> using namespace std; template<typename T> void f(T t){ c

原创 c++代碼示例及其他

0、基本語法 0.1、c++11範圍for 即:for (auto n : arr) 0.2、c++中宏的字符化操作(#@) 0.3、c++中宏的標記連接操作(##) 0.4、c++中宏的字符串化操作(#) 0.5、c++中 a+

原创 c++ C2912 錯誤演示

//by 鳥哥 vs下的C2912 錯誤 //有疑問請留言或加羣 1032082534 template <> void test(const int& p) {} //如果寫在這裏vs 會報C2912,gcc會報 error