c++ - Can't initialize static QList? -


i following error:

cube.cpp:10: error: expected initializer before ‘<<’ token

here's important parts of header file:

#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 

here's line gives error:

qlist<int> cube::colorlist << yellow << red << green << orange << blue << white; 

you can't initialize object <<. = there not operator=() -- it's special syntax same calling constructor.

something might work

qlist<int> cube::colorlist = emptylist() << yellow << red << green << orange << blue << white; 

where emptylist() is

qlist<int> emptylist() {    qlist<int> list;    return list; } 

and copy construction of list, , barring optimization, copy of list created.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -