Multi compiler pass??

I am really stuck with something, it took me a while to work out why but it seems c++ does no passing to gain knowelage of identifiers.

eg, this doesnt work:

1
2
3
4
5
6
7
8
9
void a ()
{
 b();
}

void b ()
{
 do something
}


Is there a compiler directive or something to tell it that post-declarations exist? The only way i have found so far is to create a prototype of it :/ problem is i have 100s of functions that i would rather keep in alphabetical order.
Last edited on
If you need alphabetical order, do:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void a ();
void b ();
void c ();
// et cetera, et cetera
int main()
{
//your main stuff
}
void a ()
{
// ...
b();
}
void b ()
{
//do whatever
}
//et cetera again, et cetera again 


MAKE SURE YOU PROTOTYPE. I cannot stress that enough, even if I bolded it, italicized it, and underlined it.
Last edited on
Hmm ok thanks, looks like i am stuck with prototypes (I am a c# programmer normally so have been spoiled with the ability to declare stuff all over the place :)

So how can you pre-declare classes and functions or items in separate namespaces/classes then?
Last edited on
You should be fine declaring them in a header as long as you #include the header.
Topic archived. No new replies allowed.