常变量的不正确使用
#include <iostream>
using namespace std;
int main(void)
{
const int count = 3;
int *p = &count;//这里是大范围指向小范围,编译可以通过,疑惑
//打印count次字符串Hello C++
for (int i = 0; i < *p; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
const int count = 3;
int *p = &count;//这里是大范围指向小范围,编译可以通过,疑惑
//打印count次字符串Hello C++
for (int i = 0; i < *p; i++)
{
cout << "Hello imooc" << endl;
}
return 0;
}
2017-08-08
举报