20.10.6,學習c++的第六天
函式預設引數:
函式佔位引數:int
func
(int a,
int b =10,
int c =10)
//1. 如果某個位置引數有預設值,那麼從這個位置往後,從左向右,必須都要有預設值
//2. 如果函式宣告有預設值,函式實現的時候就不能有預設引數(宣告和實現只能有乙個預設引數)
函式過載:函式名相同 但函式引數型別不同或者個數不同或者順序不同void
func
(int a,
int)
func(10
,10);
//佔位引數必須填補
函式過載碰到函式預設引數,盡量避免//函式過載需要函式都在同乙個作用域下
void
func()
void
func
(int a)
void
func
(double a)
void
func2
(int a,
int b =10)
void
func2
(int a)
c 入門程式設計學習記錄4
20.8.5,學習c 的第四天 結構體的知識以及用法 include include using namespace std struct student struct teacher int main 結構體陣列 struct student stuarr 2 結構體指標 struct stude...
c 入門程式設計學習記錄9
20.10.19,學習c 的第九天 乙個空物件占用乙個位元組的空間。只有非靜態成員變數才屬於類的物件上。this指標指向被呼叫的成員函式所屬的物件 this指標的用途 在成員行為中使用成員屬性,預設是 this menber 空指標訪問成員函式 class person void showperso...
c 入門程式設計學習記錄8
20.10.12,學習c 的第八天 建構函式和析構函式 class person 析構函式 person 建構函式的分類與呼叫 class person 有參建構函式 person int a 拷貝建構函式 person const person p 析構函式 person public int a...