what are forward declarations

N

Neo

Hi,
I am new to C++ and want to know what are forward declarations and any
site which has a good introductory explanation.

thanks in advance,
nick
 
J

Jim Langston

Neo said:
Hi,
I am new to C++ and want to know what are forward declarations and any
site which has a good introductory explanation.

thanks in advance,
nick

See this and others:
http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.11

Basically:
// This won't compile because SomeFunction hasn't been declared before it's
used,
// so the compiler doesn't know how it's supposed to be used.
void main()
{
SomeFunction();
}

void SomeFunction()
{
// Do Something
}

// This will compile
SomeFunction(); // This is a forward declaration
void main()
{
SomeFunction();
}

void SomeFunction()
{
// Do Something
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top