[Qt-interest] tracking uniqueness
Andreas Pakulat
apaku at gmx.de
Fri Apr 23 16:22:14 CEST 2010
On 23.04.10 15:14:53, Oliver Heins wrote:
> Andreas Pakulat <apaku at gmx.de> writes:
> > On 23.04.10 11:29:01, Oliver Heins wrote:
> >
> > The only way I can see to make this work is use a send in the id for Token
> > in its constructor, i.e.:
> >
> > Token( int id_ ) : id(id_) {}
> >
> > and then have the member variable on Editor.
>
> I'll give that a try, but I think I'm in the need of a default
> constructor.
Thats not possible unless you accept having a global counter.
> > There's no way to make a counter for unique numbers per Editor
> > instance without knowing the Editor instance.
>
> Even though class Token is a nested in Editor? There can't be an
> instance of Token without a surrounding instance of Editor.
You seem to have a bit of misconception about this. There is no Editor
instance in your code. All you do is declare a class and a nested class,
both can be used without an instance of the other as far as your example
goes. In particular, this:
class Editor
{
public:
class Token
{
};
};
Editor::Token t;
is perfectly valid compiling code. And there's no instance of Editor
generated here, there's only a single instance of Token.
Andreas
--
While you recently had your problems on the run, they've regrouped and
are making another attack.
More information about the Qt-interest-old
mailing list