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

Ordering of class definitions

P: n/a
Hi People,

Quick question. Do class definitions for base classes (and for classes
of embedded objects) have to appear prior to their derived classes? I
would have thought that matters of ordering would not be so important.

Cheers,

Deets
Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> Quick question. Do class definitions for base classes (and for classes
of embedded objects) have to appear prior to their derived classes? I
would have thought that matters of ordering would not be so important.


Of course. How would othervise compiler know how to properly compile derived
class?

One solution is to write an interface in a separate file, and then just to
include that file in derived class file.
Jul 22 '05 #2

P: n/a
Anon Email wrote:
Hi People,

Quick question. Do class definitions for base classes (and for classes
of embedded objects) have to appear prior to their derived classes?
Yes. If those classes are not defined yet at this point, how would the
compiler know anything about them?
I would have thought that matters of ordering would not be so
important.


They are important.

Jul 22 '05 #3

P: n/a
"Anon Email" <an********@fastmail.fm> wrote in message
news:83*************************@posting.google.co m...
Hi People,

Quick question. Do class definitions for base classes (and for classes
of embedded objects) have to appear prior to their derived classes? I
would have thought that matters of ordering would not be so important.

Cheers,

Deets


Quick answer. Yes.

Slightly longer answer. You might be able to alleviate the problem (for
contained members) by just declaring the classes and storing them in a smart
pointer, since Foo does not need to be defined for you to have a Foo&, a
Foo*, or a boost::scoped_ptr <Foo>.

HTH
--
KCS
Jul 22 '05 #4

P: n/a
Thanks guys.
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.