# Recurring method of decommissioning a two-strong componer

• Hello, help us to implement the recurring algorithm of the withdrawal of all elements. Example of conclusion: [1.2.0,false,[1,2],4.2,[1,[2],true]], where [] container. Maybe we should start at the top, get the contents of the container out, if the container goes back to the end. But where do we start? I don't know how to overload the cement and the container.

I'm going to sleep, I'm gonna be in the morning.

``````class base
{
public:
virtual bool Equals(base *n) = 0;
virtual void ToString(char* bufer) = 0;
virtual ~base() {}
};
class element : public base
{
public:
union {
int iVar;
float fVar;
bool bVar;
};
public:
element(int var) { iVar = var; }
element(float var) { fVar = var; }
element(bool var) { bVar = var; }
bool Equals(base* n) {
element* p = dynamic_cast&lt;element*&gt;(n);
if (bVar == p-&gt;bVar || fVar == p-&gt;fVar || iVar == p-&gt;iVar) {
return true;
}
else {
return false;
}
}
bool operator == (element* n)
{
if (bVar == n-&gt;bVar || fVar == n-&gt;fVar || iVar == n-&gt;iVar) {
return true;
}
else {
return false;
}
}
void ToString(char* buffer) {

}

};
class container : public base
{
public:
private:
base*** array;
int order;
int ni; int nj; //последний элемент
public:
container(int ord) {
ni = 0; nj = 0;
order = ord;
array = new base**[order];
for (int i = 0; i < order; i++) {
array[i] = new base*[order];
for (int j = 0; j < order; j++) {
array[i][j] = NULL;
}
}
}
~container() {
for (int i = 0; i < order; i++) {
if (array[i]) {
delete[] array[i];
}
delete[] array;
array = NULL;
order = 0;
}
}
bool Add(base n) { //добавление элемента в конец
array[ni][nj] = n;
if (nj != order - 1) {
nj++;
return true;
}
else if (nj == order - 1 && ni != order - 1) {
nj = 0; ni++;
}
else if (nj == order - 1 && ni == order - 1) {
return false;
}
return false;
}
bool Equals(base n) {
container* p = dynamic_cast<container*>(n);
bool full = true;
for (int i = 0; i < order; i++) {
for (int j = 0; j < order; j++) {
if (array[i][j] != p->array[i][j]) {
full = false;
}
}
}
return full;
}
void ToString(char* buffer) {
};
};
``````

• You certainly need that kind of performance. `union`the three-indicator `base***` etc.?

I mean, it's easy to write a classic conclusion. Checking your own. `base`♪ If it is. `element`just get him out and come back. If it is. `container` - Get out. `[`then pass through all the elements in it, causing each function of withdrawal. After completion - `]`♪ With the commas, you'll figure out:

How will you determine that it is from the association now in your element and how to remove it, I don't know if you add an extra field.

In fact, it all resembles attempts to tie ropes to different parts of the bike in the hope of getting a motorcycle. For example, for starters, answer questions:

• What is justified by the use `union`?

• Why are the data in the class? `public`?

• What happens when you're in. `dynamic_cast` Is your index not what you expected?

• Is it necessary? `base***array`? Should we use some standard container?

• You don't find an unreliable test. `if (bVar == p->bVar || fVar == p->fVar || iVar == p->iVar)`? What if a young White matches a whole bunch of numbers, like... ♪ ♪

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2