//const
#include <iostream>
using namespace std;
int main(void)
{
//定義常量count
const int count = 3;
const int *p = & count;
//打印count次字符串Hello C++
for(int i = 0; i < count; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//定義常量count
const int count = 3;
const int *p = & count;
//打印count次字符串Hello C++
for(int i = 0; i < count; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}
最新回答 / 寅月
但是視頻上說(shuō) const int *p和int const *p沒(méi)有區(qū)別啊,區(qū)別指針常量和常指針不是區(qū)別*在const左邊還是右邊嗎?
2017-08-20
最贊回答 / ufan0
inline是C++關(guān)鍵字,并且用網(wǎng)絡(luò)上講得的詳細(xì)點(diǎn)說(shuō)法就是在函數(shù)聲明或定義中函數(shù)返回類型前加上關(guān)鍵字inline,即可以把函數(shù)指定為內(nèi)聯(lián)函數(shù)。關(guān)鍵字inline必須與函數(shù)定義放在一起才能使函數(shù)成為內(nèi)聯(lián),僅僅將inline放在函數(shù)聲明前面不起任何作用。inline是一種“用于實(shí)現(xiàn)的關(guān)鍵字”,而不是一種“用于聲明的關(guān)鍵字”。一般的,用戶可以閱讀函數(shù)的聲明,但是看不到函數(shù)的定義。
2017-08-13
#include<iostream.h>
int main(void)
{
const count=3;
const *p=&count;
for(int i=0;i<=*p;i++)
{
cout<<"hello,world"<<endl;
}
return 0;
}
int main(void)
{
const count=3;
const *p=&count;
for(int i=0;i<=*p;i++)
{
cout<<"hello,world"<<endl;
}
return 0;
}
#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;
}
#include<iostream.h>
int main(void)
{
int x=3;
int &y=x;
cout<<"x="<<x<<",y="<<y<<endl;
y=4;
cout<<"x="<<x<<",y="<<y<<endl;
}
int main(void)
{
int x=3;
int &y=x;
cout<<"x="<<x<<",y="<<y<<endl;
y=4;
cout<<"x="<<x<<",y="<<y<<endl;
}
c 語(yǔ)言{
申請(qǐng) void *malloc(size_t size);
釋放 void free(void *memblock);
}
申請(qǐng) void *malloc(size_t size);
釋放 void free(void *memblock);
}
2017-08-03