Perhaps you could shed light on - I presume - my confusion with
regard to the the use of - what the article calls - 'back pointer'.
So now, consider
//////////////////////////////
// bar.h
#ifndef BAR_H
#define BAR_H
# include <memory>
class FOO;
class BAR
{
public:
BAR();
~BAR();
private:
FOO* foo;
};
#endif
Copy constructor and assignment operator omitted for brevity, right? ;-)
//////////////////////////////
//bar.cpp
# include "foo.h"
# include "bar.h"
BAR::BAR() : foo( new FOO(this) ) { } // (1)
BAR::~BAR() { delete foo; }
//////////////////////////////
//foo.h
#ifndef FOO_H
#define FOO_H
# include <memory>
# include "bar.h"
class BAR;
class FOO
{
public:
FOO(BAR* bar_);
~FOO();
private:
BAR* bar;
};
//////////////////////////////
//foo.cpp
# include "foo.h"
# include <iostream>
FOO::FOO(BAR* bar_) : bar(bar_) {}
FOO::~FOO() { }
//////////////////////////////
//main.cpp
# include<iostream>
# include "foo.h"
# include "bar.h"
int main()
{
BAR *ptrBar = new BAR;
delete ptrBar;
return 0;
}
Per line "(1)" above.
Isn't it safe to state that the 'foo' object is created using a an
'incomplete' bar object?
Well, I think it's best to say that FOO's constructor is passed a pointer to
a BAR object whose constructor has not finished executing. In those cases,
it is best if FOO does not access the object, because the object may be in
an inconsistent state, and all sorts of nastiness can happen if you're not
careful. If this were the pimpl idiom, then it looks like FOO is BAR's
implementation class, and FOO shouldn't have any reason to do anything with
the instance of BAR.
Is there alternative when dealing with a 'scenario' such as this?
There's nothing wrong with the above code. I think Sutter's complaints
about the back pointer concerned efficiency ("extra level of indirection").
I don't see much of a problem with this:
// Typical pimpl header w/forward declaration and pImpl_ member
#include "Foo.h"
struct FooImpl {
int usedToBePrivate;
// can't depend on "this" for access to Foo, so take an argument
void usedToBePrivateToo(Foo * self);
};
void Foo:

ublicMember(){
// ...
pImpl_->usedToBePrivateToo(this);
}
The fact that he referred to the back pointer as "self_" instead of "self"
makes me wonder if the back pointer was a member of the implementation
class. I wouldn't bother doing that. That would just make the
implementation object larger for (IMHO) little benefit. I suppose it could
be argued that it's more readable if it's a member.