struct foo {
/* some things defined here */
};
foo someArray[] = {
{ /* values for first element */ },
{ /* values for next element */ },
/* repeat unknown number of times */
};
int main()
{
/* hackish loop? Does work though */
int i = 0;
while (true)
{
try { //Should just catch an exception if no such element
if (someArray[i].whateverValue)
{
/* do some stuff */
}
} catch (int e) {
break;
}
i++;
}
return 0;
}
root @w3style /home/d11wtq/cpp# g++ test.cpp -o test.out
test.cpp:7: error: expected constructor, destructor, or type conversion before ‘.’ token
What have I missed? Hmm... wish we had a n00b-friendly C++ forum
EDIT | One big advantage to stl::list (if I can figure it out) is that I can store my token defintions in a defintion file like this and read it at runtime rather than compile-time.
Btw, i prefer to compile with all warnings, g++ -Wall source -o output.
For a simple program testprogram i've added the following to my .vimrc (compile with F9 and run with F10)
For larger projects there is always :make but that's for another time..