这是做什么的?C++

What will this do? C++

本文关键字:C++ 什么      更新时间:2023-10-16
void main()
{
    int const *p=5;
    cout<<++(*p);
}

这是做什么的?是错的吗,如果是错的,为什么?请让我理解。谢谢!

这是做什么的?

程序格式不正确,可能会拒绝编译。如果编译,则标准未指定行为。

是错的吗,如果是错的,为什么?

是的。因为:

error: '::main' must return 'int'
error: invalid conversion from 'int' to 'const int*'
error: 'cout' was not declared in this scope
error: increment of read-only location '* p'