常變量的不正確使用
#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
舉報
2017-08-08
這個和編譯軟件有關,我用的code blocks就編譯不過