By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,501 Members | 1,704 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,501 IT Pros & Developers. It's quick & easy.

what are forward declarations

P: n/a
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

Nov 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Neo" <zi*********@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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-lit...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
}
Nov 22 '05 #2

P: n/a
On 2005-11-21 20:05, Neo wrote:
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


Forward declarations is a way to tell the compiler that there exists a
class with a certain name, but you don't tell it what it is.

A good example and explanation from the FAQ:
http://www.parashift.com/c++-faq-lit...html#faq-39.11

Erik Wikström
--
"I have always wished for my computer to be as easy to use as my
telephone; my wish has come true because I can no longer figure
out how to use my telephone" -- Bjarne Stroustrup
Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.