I have this (simplified) situation:
class Tree {
class Iterator {
class Stack {
// ...
}
public:
// ...
}
public:
//...
}
I don't want to clutter the classes' definitions and I decide to write only method declarations inside classes themselves. Later on (waaay down below) when I want to define, say, copy assignment operator like this:
Tree::Iterator::Stack& Tree::Iterator::Stack::operator = (const Stack& p_stack) {
// ...
}
I have to deal with these nasty scope resolutions. I'm wondering if there's a way to shorten them, because using
and typedef
, as I know them, don't offer me anything.
EDIT: Since this is not CodeReview, and @Yulian requested clarification, here's the short version:
I'm making an iterative Red-Black Tree implementation. Mentioned class Iterator
is for post-order traversing (so it's post-order-specific), and class Stack
is its utility class. In this short program, only class Tree
uses the Iterator
, and only Iterator
uses Stack
.
After @Yulian's reminder, I recalled that it would be way more object-oriented if the mentioned classes were separately defined (maybe even as templates), but this is a small, self contained program and I'm trying to keep it that way.
EDIT: Self-contained also means that it's an isolated, single-file program, so no .h files or external code re-using whatsoever. Why? Because ACADEMIA (and associated arbitrary restrictions).
using
andtypedef
buy you anything? – Marcellusmarcelousing Stack = Tree::Iterator::Stack;
or something similar -Iterator
andStack
are inaccessible. – Dicastusing
declarations inside each function definition. – PinskTree
public interface to be directily accessible. – Dicast