Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++ circular dependencies

Name: Anonymous 2007-07-10 22:35 ID:hlN0Scis

Dependency shit is one of the biggest reasons I hate C++. Consider these two files:

--- A.h ---

//forward declaration

class A {
    ...
    void doStuff( vector<B>& );
}

--- B.h ---

#include "A.h"

class B {
    ...
    A a;
}

---


I need to put some kind of forward declaration in A.h for the vector<B>& parameter. Anybody have any idea what I'm supposed to put there? Because I don't have a clue.

Attempts like this:
template <class T> class vector;
cause Eclipse to permanently freeze. It's not surprising to find yet another bug in Eclipse (or CDT), but still.

What kind of horrible language would do this to people?!

Name: Anonymous 2007-07-10 22:38 ID:Heaven

stop using eclipse, you faggot.

Name: Anonymous 2007-07-10 23:01 ID:UsrLaX87

Sounds like an IDE related issue. C++ is fine.

Name: Anonymous 2007-07-11 0:23 ID:s1dMBZjS

Try storing B* in your vector instead, and using a forward class declaration like class B in A.h. Forward references allow you to use class pointers and references without them having been fully defined yet.

If you think about it, since members of a class are stored in-place, a circular reference is really trying to make a class of infinite size.

Name: Anonymous 2010-11-25 5:19

Name: Anonymous 2010-11-25 20:29

Name: sage 2011-07-25 23:19

<code>
anus
  anus
    anus
</code>

Name: Anonymous 2013-08-31 7:41


There is a transfinite sequence of cardinal numbers:
    0, 1, 2, 3, ..., n; ℵ0, ℵ0, ℵ1, ... ℵα, ...

Name: Anonymous 2013-08-31 8:25


(κ ≤ μ) → (κν ≤ μν).

Name: Anonymous 2013-08-31 9:11


 It is therefore assumed by physicists that no measurable quantity could have an infinite value, for instance by taking an infinite value in an extended real number system, or by requiring the counting of an infinite number of events.

Name: Anonymous 2013-08-31 9:57


Each set in this hierarchy is assigned (by transfinite recursion) an ordinal number α, known as its rank. The rank of a pure set X is defined to be the least upper bound of all successors of ranks of members of X.

Name: Anonymous 2013-08-31 10:42


Many discussions of "classes" in the 19th century and earlier are really referring to sets, or perhaps to a more ambiguous concept.

Name: Anonymous 2013-08-31 11:27


But some subsets of the real numbers do not have least elements. For example, the open interval (0,1) does not have a least element: if x is in (0,1), then so is x/2, and x/2 is always strictly smaller than x. So this attempt also fails.

Don't change these.
Name: Email:
Entire Thread Thread List