前言
本技術文檔是個人知識的總結再次整理髮布出來共大家共同進步和修正。如果有發現不對之處請聯繫我更正,共同學習和進步。
QQ羣:496851698
文檔不是詳細開發教程所以不適合入門。
變量
boot true/false
char 8byte
short 2byte
int 4byte
long 32位系統 4byte, 64位系統8byte
long long 8byte
flot 4byte
double 8byte
整形變量都可以增加 unsigned 表示最高位不充當符號位
命名空間
// 第一個命名空間
namespace first_space{
void func(){
cout << "Inside first_space" << endl;
}
}
int main ()
{
// 調用第一個命名空間中的函數
first_space::func();
return 0;
}
//引用命名空間
using namespace first_space;
int main ()
{
// 調用第一個命名空間中的函數
func();
return 0;
}
c++11
using 定義別名 using fun = void (*)(); 同typedef
using /*使用外部構造*/
class Base
{
public:
Base(int va) {}
};
class Derived :public Base
{
public:
//使用繼承構造函數
using Base::Base
}
//模板別名
template <typename T>
using ArenaQueue = std::queue<T, ArenaDeque<T>>;
類
//說道類我要說兩句。個人感覺類是一個在程序裏面實現高內聚、低耦合的很簡潔的方式。
//public 類外部可以訪問
//protected 子類可以訪問,外部不能訪問
//private 只能本類訪問
//delete 刪除該類型函數,程序中不可調用,調用會報錯
//defaulte 指定默認構造函數
//explicite 防止類構造函數的隱式自動轉換
//final 終結虛函數傳遞, 子類不能再實現該函數
//override 說明該函數式覆蓋函數,父類必須有其相同定義
class FirstClass {
public:
int getLength( void );
FirstClass (bool ) = delete;
FirstClass (char ) = default;
explicite FirstClass ( int len ); // 簡單的構造函數
FirstClass ( const Line &obj); // 拷貝構造函數
~FirstClass (); // 析構函數
virtual void vir_fun(); //虛函數 類多態使用
virtual int area() = 0; //不用給出實現 派生類必須實現
protected:
private:
}
//繼承
//public 保持之類的訪問屬性 即: public protected private
//protected 改變繼承的 public訪問控制位 protected,其他不變
//private 改變繼承的 protected public爲 private
//子類只能訪問父類 protected public的成員不能訪問 private的成員
class ChildClass : public FirstClass{
using FirstClass::FirstClass;
final void vir_fun() {}
final int area() {}
override int getLength() {}
}
//多態
FirstClass *firstClass = (new ChildClass(5));
firstClass->vir_fun() //執行ChildClass類的函數