I'm trying to create a QVector of multidimensional array(C++ array class) but I'm facing troubles with it
I have a class "node" and I want to pass the QVector of a multidimensional array as a parameter of the node class construct but this isn't working, I'm a getting a compile error!
Class node {
node(QVector<array<array<int, SIZE>, SIZE>> v);
}
any one has an idea of how should I proceed?
node(QVector, SIZE>> v);
That will not compile without C++11 and on. You need two ways to address it:
node(QVector<array<array<int, SIZE>, SIZE> > v);
// ^space
node(QVector<array<array<int, SIZE>, SIZE> > v);
Correct, no change; it just works. Put this into your qmake project file:
CONFIG += c++11
However, since you seem to use "C++ array", you will need the latter solution. In other words, just add c++11 compilation support to you build.
You have further issues, too:
I am not sure where you got the idea of capital for the Class
. It should be written class
.
Also, you inherently need the separator (;
) after a class.
You better do not use array
in header files, but std::array
.
This is my working example:
#include <QVector>
#include <array>
const int SIZE = 5;
class node {
node(QVector<std::array<std::array<int, SIZE>, SIZE>> v) {}
};
int main()
{
return 0;
}
TEMPLATE = app
TARGET = main
CONFIG += c++11
SOURCES += main.cpp
qmake && make && ./main