-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'沒有類型) –