最新回答 / 慕慕6147433
當(dāng)const已經(jīng)修飾一直變量時,再去用指針去指這個變量會很危險,因為指針可以改去該變量的值,與const就有沖突的風(fēng)險,const int *p=&a和const int * const p=&a是可以的,這樣保證了*p的值不能改變,所以就不會有與const沖突的可能性。
2017-09-10
最新回答 / 青鬃
james_yuan ? 慕課網(wǎng)中搜索一下這個人,我c++課程都是看他的視頻學(xué)的,感覺比我的大學(xué)老師講得好(emmm...畢竟課堂上講的代碼只能干看著不能邊學(xué)邊敲很無聊的)
2017-09-08
已采納回答 / 慕粉1527144879
你先把這行代碼注釋掉自行看看結(jié)果,然后再加上這行代碼你就會知道它的意思(執(zhí)行的重載函數(shù)int getMax(int a, int b))
2017-09-05
#include <string.h>
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申請100個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)
{
//在堆中申請100個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;
}