我感覺沒學(xué)過C直接看這個(gè)真沒幾個(gè)人能懂。有很多操作都是有一點(diǎn)基礎(chǔ)才看得懂的.真心話!?。?br />
時(shí)間: 2016-08-30
2016-12-21
int main(void)
{
//定義int數(shù)組并初始化
int numArr[3] = {3, 8, 6};
//自動(dòng)調(diào)用int getMax(int a, int b)
cout << getMax(3, 6) << endl;
//自動(dòng)調(diào)用返回?cái)?shù)組中最大值的函數(shù)返回?cái)?shù)組中的最大值
cout << getMax(numArr,3) << endl;
return 0;
}這樣可以通過。
{
//定義int數(shù)組并初始化
int numArr[3] = {3, 8, 6};
//自動(dòng)調(diào)用int getMax(int a, int b)
cout << getMax(3, 6) << endl;
//自動(dòng)調(diào)用返回?cái)?shù)組中最大值的函數(shù)返回?cái)?shù)組中的最大值
cout << getMax(numArr,3) << endl;
return 0;
}這樣可以通過。
看 const 右邊開始 是修飾誰 ?
int a =5;
int const *p = &a,const 修飾 *p ,*p 不能變; a =10?, *p=10 ?;
int * const p = &a, const 修飾 p, p不能變;
int a =5;
int const *p = &a,const 修飾 *p ,*p 不能變; a =10?, *p=10 ?;
int * const p = &a, const 修飾 p, p不能變;
2016-12-01
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請(qǐng)100個(gè)char類型的內(nèi)存
char *str = new char[100];
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//釋放內(nèi)存
delete []str;
str = NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請(qǐng)100個(gè)char類型的內(nèi)存
char *str = new char[100];
//拷貝Hello C++字符串到分配的堆中的內(nèi)存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//釋放內(nèi)存
delete []str;
str = NULL;
return 0;
}
實(shí)例再多點(diǎn),推薦點(diǎn)寫的好的相關(guān)博客,或者其他免費(fèi)的優(yōu)質(zhì)技術(shù)資源就好了。。(原諒我的貪心和貧窮)
2016-11-24
說一個(gè)比較好記的方法來區(qū)分 int const *p與 int* const p,把*讀作pointer to然后從后往前讀.
第一個(gè)int const *p就可以讀作 p is a pointer to const int,p是指向常量的指針
第二個(gè)int* const p就可以讀作 p is a const pointer to int,p是指向int型的常指針
第一個(gè)int const *p就可以讀作 p is a pointer to const int,p是指向常量的指針
第二個(gè)int* const p就可以讀作 p is a const pointer to int,p是指向int型的常指針
2016-11-23