just wondering if there is a set way of doing structs in qt. i have made structs before in the past using C, but im not too sure about using C++ to do it and to make it work with the Qt stuff. any idea's???
Printable View
just wondering if there is a set way of doing structs in qt. i have made structs before in the past using C, but im not too sure about using C++ to do it and to make it work with the Qt stuff. any idea's???
Try the same way as in C :)
Code:
struct Point { int x; int y; };
BTW. Structs are treated by C++ as public classes, so you can add methods to them.
ah ok thankyou...whilst im on the subject of storage, would it be easier to have a 2-d array of booleans or an array of linked lists??how would i create a 2-d array of booleans anyway because ive never tried it before - even with C??
Ah... so that explains why Fullmetalcoder can, in the "devqthighlighter.h" header of his "DevQt" project, useQuote:
Originally Posted by wysota
It compiles with a ton of warnings, an executable, but no errors. If I change the declaration to "struct CodeBlock;" and compile then I get a ton of errors and no executable.Code:
class CodeBlock; .... .... struct CodeBlock{ ... }
It depends. In general there are no such things as 2D arrays. How many bools do you need in each "row"? Maybe you could use bit fields?Quote:
Originally Posted by therealjag
well i'd probably need around 30 maximum but around 10 would do for now....what are bit fields though i have never used them before?Quote:
It depends. In general there are no such things as 2D arrays. How many bools do you need in each "row"? Maybe you could use bit fields?
Then bitfields will do fine.
Code:
struct bfentry{ unsigned int one:1, two:1, three:1, four:1, //... thirtytwo:1; }
The above structure occupies.... 4 bytes :) Making it an array is easy now;
Of course you can also use: std::vector< std::vector< bool > >
Dear All,
I've a similar problem, i need a global struct such as:
I've put the previous code in a .h file and the follow:Code:
struct _Stxy1000{ double dY[1000]; double dX[1000]; }
in a .cpp file which include the .h as definition.Code:
struct _Stxy1000 _stxy1000;
When i use the struct field members in a .cpp, the compiler rise up some problems, such as "multiple definition" of the _stxy1000 variable.
Do you think i should use extern in the declaration?
Could you please post a c-like code??
Thanks in advance.
Andrea
I think you should definitely end your structure definition with a semicolon.