小编rem*_*230的帖子

'this' 不能用在带有 this-> 指针变量的常量表达式错误 (C++) 中

我收到此错误消息,我知道这是因为数组中的参数必须是常量,但我不确定如何安排我的 'this-> V; 保持不变。有什么帮助吗?我提供了大部分代码,以便指针变量的功能在整个程序中都很明显。

// A class that represents an undirected graph
class Graph
{
int V;    // number of vertices
list<int> *adj;    // A dynamic array of adjacency lists
int *in;
public:
// Constructor and destructor
Graph(int V);
~Graph() { delete[] adj; delete[] in; }

// function to add an edge to graph
void addEdge(int v, int w) { adj[v].push_back(w);  (in[w])++; }

// Method to check if this graph is Eulerian or not
bool isEulerianCycle();

// Method to check …
Run Code Online (Sandbox Code Playgroud)

c++ error-handling

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

error-handling ×1