I am working on creating a linked list in c++, and I can't figure out how to pass an array as an argument in the constructor, or if thats even legal syntax.
This is the error I get:
CheckTextFile.cpp: In constructor ‘Node::Node(char*, int)’:
CheckTextFile.cpp:19: error: incompatible types in assignment of ‘char*’ to ‘char [0u]’
CheckTextFile.cpp: In constructor ‘Node::Node(char*, int, Node*)’:
CheckTextFile.cpp:24: error: incompatible types in assignment of ‘char*’ to ‘char [0u]’
Here is my code:
class Node{
public:
int length;
char data[];
Node * next;
Node(char x[], int y){
data = x;
length = y;
next = NULL;
}
Node(char x[], int y, Node * z){
data = x;
length = y;
next = z;
}
};