C 對C的擴充

2021-08-02 23:32:33 字數 681 閱讀 6351

int a;

int &b=a; //宣告b是乙個整型變數a的引用變數

型別可以被「過載(霧)」

#includeusing namespace std;

template //函式模板

t max(t a, t b, t c)

int main()

內建函式是在編譯時,將所呼叫函式的**嵌入到

主函式中。

inline int max(int a,int b)//宣告內建函式 (也可以在類內用)

#include#include using namespace std;

#define pi 3.14

const float pi = 3.14;

class student

};void student::display()//類外定義

student stud1, stud2;

int main()

new 運算子的一般格式

new 型別 [初值];

delete 運算子的一般格式

delete [  ] 指標變數;

1 3 C 對C的擴充

asm bool true false wchar t namespace using class public protected private friend this inline virtual throw try catch new delete explicit mutable expo...

《C 程式設計教程》 C 對C語言的擴充

c 型別轉換符一共有四種 static cast expression const cast expression dynamic cast expression reinterpret cast expression 1 static cast 最常用的型別轉換操作符,它主要執行非多型的轉換,用於...

C 對C的擴充 動態陣列例子

從堆記憶體中獲取乙個整型陣列,賦值後並列印出來。include using namespace std void main 分配記憶體空間 for int i 0 i p i 0 cout output the array 0 i cout cout p 釋放記憶體空間 1.改進該程式,將動態分配陣...