POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Days 1-5 Server Time
29 Jul 2024 22:34:05 EDT (-0400)
  Re: Days 1-5  
From: Invisible
Date: 20 Apr 2012 09:02:12
Message: <4f915e54$1@news.povray.org>
>> I'm currently trying to work out how I can compile a program where
>> module 1 refers to module 2, but module 2 also refers to module 1. As
>> far as I can figure out, this is impossible...
>
>    The only thing that's impossible for a class to have another class
> as member variable, and that another class having the first class as
> member variable.

Yeah, that's exactly what I'm trying to do.

Actually, no, wait... Class X has class Y as a member, but class Y only 
/mentions/ class X. (It has member functions that return objects of 
class X.)

> (For obvious reasons. It would be an infinitely large class.)

It can if at least one of the classes refers to the other through a 
pointer or a reference. (Think about it: A binary tree class has no 
problem containing /itself/ as a member variable or two.)

So, the way I see it, I have two options:

1. Put class X and class Y in the same header file.

2. Start throwing unchecked casts around the place.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.