#include
using
std::cout;
int compare(int x, int *p)
int main()
#include
#include
using
namespace
std;
void print1(int a, int n)
}void print2(int *beg, int *end)
}void print3(int (&a)[10])
}int main()
; print1(arr, end(arr) - begin(arr));//end()與begin()都在std命名空間中。在標準庫中定義
cout
<< endl;
print2(begin(arr), end(arr));
cout
<< endl;
print3(arr);
return
0;}
main 帶引數
以下**。。。。失敗了。。。。
這是為什麼呢。
#include
using
namespace
std;
int main(int argc, char* argv)
含有可變引數的函式
和vector 一樣,initializer_list 也是一種模板型別,物件中的元素永遠是常量,
#include
using
namespace
std;
int f(initializer_list num)
return sum;
}int main()
, num2;
cout
<< f(num1) << endl
<< f(num2);
return
0;}
以上程式,,型別是vector也可實現。。。。
返回值
C Primer學習筆記 (二)
case true string file name getname break case false 這個 不行,想想 如果先執行了 false,然後false 裡面用到了 file name 怎麼辦?會提示沒有定義 並且編譯器會報錯 dev c 嘗試了 因此要在 true 後新增大括號 表明區域...
C Primer學習筆記(二)
繼續。1.size t和string size type,vector size type.bitset的size函式返回值型別是size t。string和vector的size函式返回值型別是對應的size type size t 是乙個於機器無關的unsigned型別,其大小足以儲存記憶體物件...
c primer學習筆記(二)
1.從const 成員函式返回 this 在普通的非 const 成員函式中,this 的型別是乙個指向類型別的 const 指標,可以改變 this 所指向的值,但不能改變 this 所儲存的位址。在 const 成員函式中,this 的型別是乙個指向 const 類型別的 const 指標,既不...