原创 C++11 auto_ptr shared_ptr unique_ptr

/************************************************************************* > File Name: ptr.cpp > Author: yangjx > M

原创 gdb調試或者打印地址時候爲啥只有48位?

例如:0x7fffd2f48c10 根本原因:當前的x86_64處理器硬件限制所致。因爲目前面世的x86_64處理器的地址線只有48條,硬件要求傳入的地址的48到63位必須與47位相同。 因爲這個相同的原因也就是說剩下的16位要那麼是 0

原创 shell腳本批量創建刪除賬號

#!/bin/bash USERS_INFO=/root/addusers.txt USERADD=/usr/sbin/useradd USERDEL=/usr/sbin/userdel PASSWD=/usr/bin/passwd

原创 代碼構建 premake4 例子

Building the Source Code //構建代碼 Premake can be built in either "release" (the default) or "debug" modes. If you are usi

原创 C++ 基類 派生類 互相轉換 調用關係

#include<iostream> using namespace std; class A { public: A(int a) : _a(a ) { std::cout << "this is A" << _a <<

原创 字符串化操作符#得作用

#include <stdio.h> #define f(a, b) a##b #define g(a) #a #define h(a) g(a) int main() { printf("%s\n", h(f(1,2

原创 C++ shared_ptr 編譯 error ‘shared_ptr’ was not declared in this scope修復

#include<iostream> #include<cstring> #include<string> #include<memory> using namespace std; class Simple { public

原创 C++ 容器 new 刪除問題

#include<iostream> #include<vector> using namespace std; int main() { std::vector<int*> a; int* b = new int(10

原创 C++ 類複製

#include<iostream> using namespace std; class A { public: A(): a(0), b(0) {} A(int s, int ss): a(s

原创 位操作實現m的n次方

#include <stdio.h> #include <stdlib.h> int pow(int m, int n) { int sum = 1; while(n != 0) { if(n&

原创 C++ new map erase delete 不delete時候重複使用問題 各種情況測試代碼

#include <iostream> #include <map> using namespace std; #include <stdio.h> struct A { int x; int y; A

原创 go語言 面向對象 面向過程舉例解釋

package main import "fmt" type intt int //面向對象 func (a intt) less(b intt) bool { return a > b } //面向過程 func

原创 c signal函數與system函數小應用

#include<sys/types.h> #include<iostream> #include<stdio.h> #include<stdlib.h> #include<errno.h> #include<unistd.h> #in

原创 C++ 實際項目中設置全局變量三種方法

#include<iostream> using namespace std; #include<stdlib.h> #include<stdio.h> /** method one *****/ template<typenam

原创 C++ template模版長期舉例總結

example_1 #include<iostream> using namespace std; #include<stdio.h> template<typename T> class ID { public: I