Topic: Is it legal to use 'this' in the initializer list of a constructor
Author: brettb@acti-ct.com (Brett Bergquist)
Date: 1996/04/04 Raw View
consider the following classes:
class bar;
class foo
{
public:
foo(bar* b) : m_b(b) {}
private:
bar* m_b;
};
class bar
{
public:
bar() : m_f(this) {}
// ^^^ is this legal
private:
const foo m_f;
};
Is the use of 'this' legal to initialize the constant foo member. If
not, how does one get a pointer to object being constructed within
the constructor initializer?
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]