#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;
}
C++的重載的兩個函數(shù)參數(shù)數(shù)量可以相同也可以不同,當參數(shù)數(shù)量相同時,只需要對應(yīng)參數(shù)類型不同即稱為重載
2017-10-09
const后面是誰,誰就不能變,就這么簡單:
int const *p;* 是取p指向地址中的值的意思,值得就是 *p(p地址指向的值)不能變,p可以指向其他變量的地址;
int *const p; p是地址,不能變了,*p(p指向的值)可以變。
int const *p;* 是取p指向地址中的值的意思,值得就是 *p(p地址指向的值)不能變,p可以指向其他變量的地址;
int *const p; p是地址,不能變了,*p(p指向的值)可以變。
2017-10-05
指針指向const修飾的變量時 , 應(yīng)該是const int const *p = &a ; (被引用者的權(quán)限應(yīng)該大于或等于引用者)
2017-10-05