-3
我有这样的下面的代码:C++,表达必须修改的左值
#include "stdafx.h"
#include<iostream>
using namespace std;
const int x = 5;
bool graf_adj[x][x] = {
0,1,1,1,0,
1,0,1,0,0,
1,1,0,1,1,
1,0,1,0,0,
0,0,1,0,0
};
struct Graf
{
bool adj[x][x];
char n;
};
int main(){
Graf graf1;
graf1.adj = graf_adj;
}
在主要功能当我尝试assing graf_adj到graf1.adj graf1.adj = graf_adj;
编者给了我这个错误:
Error Expression must be a modifiable lvalue
有人可以解决这个问题吗?
谢谢立即
您不能分配阵列的解决方案。您可以复制其内容,例如与'memcpy'或'std :: copy' –
更好的是,使用std数组或std向量 –
这个编译('x'没有类型) –