【发布时间】:2020-03-16 16:09:18
【问题描述】:
第二次赋值出错(“int”类型的值不能赋值给“int *”类型的实体),为什么第一次赋值没有出现同样的错误?
#include <bits/stdc++.h>
using namespace std;
int main()
{
int* x = new int[100];
x[5] = 3;
int* y[100];
y[5] = 3;
return 0;
}
【问题讨论】:
-
int* y[100];是一个指向int的指针的数组。x是指向int的指针。
标签: c++ arrays pointers new-operator dynamic-memory-allocation