//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;
}
最赞回答 / ufan0
inline是C++关键字,并且用网络上讲得的详细点说法就是在函数声明或定义中函数返回类型前加上关键字inline,即可以把函数指定为内联函数。关键字inline必须与函数定义放在一起才能使函数成为内联,仅仅将inline放在函数声明前面不起任何作用。inline是一种“用于实现的关键字”,而不是一种“用于声明的关键字”。一般的,用户可以阅读函数的声明,但是看不到函数的定义。
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)
{
//在堆中申请100个char类型的内存
char *str = new char[100];
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//释放内存
delete str;
str=NULL;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
//在堆中申请100个char类型的内存
char *str = new char[100];
//拷贝Hello C++字符串到分配的堆中的内存中
strcpy(str, "Hello imooc");
//打印字符串
cout<<str<<endl;
//释放内存
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 语言{
申请 void *malloc(size_t size);
释放 void free(void *memblock);
}
申请 void *malloc(size_t size);
释放 void free(void *memblock);
}
2017-08-03