J
James Brown
Hi,
I have the following:
class outer
{
public:
outer();
private:
class inner
{
public:
inner();
};
};
In other words, a nested class. In my particular case, the inner class
definition is quite large and I'd like to define it outside of the outer
class, but still have it remain as an 'inner' class. The idea being, to keep
the code of 'outer' tidy but still have the inner class as a private class
to 'outer'.
e.g.
class outer
{
.....
// forward-declare 'inner'
class inner;
};
// define 'inner' separately from 'outer'
class outer::inner
{
.....
};
I'm getting compiler errors of course, so I'm guessing that this kind of
syntax isn't possible. What I would like to know however, is what is the
'best practice' for dealing with this kind of thing? Do I have to shrug my
shoulders and have a monolithic outer class with everything defined within
it? or is there some kind of neat design I can follow somewhere..?
thanks,
James
I have the following:
class outer
{
public:
outer();
private:
class inner
{
public:
inner();
};
};
In other words, a nested class. In my particular case, the inner class
definition is quite large and I'd like to define it outside of the outer
class, but still have it remain as an 'inner' class. The idea being, to keep
the code of 'outer' tidy but still have the inner class as a private class
to 'outer'.
e.g.
class outer
{
.....
// forward-declare 'inner'
class inner;
};
// define 'inner' separately from 'outer'
class outer::inner
{
.....
};
I'm getting compiler errors of course, so I'm guessing that this kind of
syntax isn't possible. What I would like to know however, is what is the
'best practice' for dealing with this kind of thing? Do I have to shrug my
shoulders and have a monolithic outer class with everything defined within
it? or is there some kind of neat design I can follow somewhere..?
thanks,
James