Tobias Müller <
tro...@bluewin.ch> wrote:
> "Charles T. Smith" <
cts.priv...@gmail.com> wrote:
>> Hi,
>>
>> I have a class with an inner class as an attribute. The inner class's
>> constructor takes an argument, an address to its owner:
>>
>> class o {
>> class i o(this);
>> }
>>
>> I get these errors: error:
>> error: expected identifier before 'this'
>> error: expected ',' or '...' before 'this'
>>
>> Is it not possible to have a class as an attibute and pass the
>> constructor parameters? After all, at instantiation time, at least
>> "this" and the outer class's parameters are all knowable.
>>
>> What is the explicit prohibition here, does anyone know?
>>
>> cts
>
> This is not valid C++, not even close. Did you mean something like that:
>
> class O
> {
> O(): i(this) {}
>
> class I
> {
> I(O* o): o_(o) {}
> O* o_;
> } i;
> };
>
> This should work as long as you just