私は次のエラーを取得する:静的なQListを初期化できませんか?
Cube.cpp:10: error: expected initializer before ‘<<’ token
は、ここでヘッダファイルの重要な部分です:
#ifndef CUBE_H
#define CUBE_H
#include <cstdlib>
#include <QtCore/QtCore>
#include <iostream>
#define YELLOW 0
#define RED 1
#define GREEN 2
#define ORANGE 3
#define BLUE 4
#define WHITE 5
using namespace std;
class Cube {
public:
...
static QList<int> colorList;
...
};
#endif
ここでエラーになるラインです:
QList<int> Cube::colorList << YELLOW << RED << GREEN << ORANGE << BLUE << WHITE;
ありがとうございました。私はあなたが提供したものに似た何かを使用しました。空リストの代わりに、私は新しいQList()を使用しました<< ...;それは動作するようです。この方法を使用する際に潜在的な問題がありますか? –
dfetter88
リストを作成してそれをコピーするだけです。そのような短いリストのために、アプリで一度だけ、私はそれについて心配しないだろう。 –