How to use c++ classes without names?
<p>I encountered a problem in opensource c++ code. The following is a small and simplified version to describe my problem:</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;
#define TOGETHER2(a,b) a ## b
#define TOGETHER(a,b) TOGETHER2(a,b)
#define GENERATE_NAME(a) TOGETHER(a,__COUNTER__)
#define GENERATE     GENERATE_NAME(__seed_)
class base{
}b;

class GENERATE:public base{
}GENERATE;

class GENERATE:public base{
}GENERATE;

class GENERATE:public base{
}GENERATE;

class GENERATE:public base{
}GENERATE;

int main(){
    return 0;
}
</code></pre>

<p>As we can see, the author defines several classes, which inherites a base class. But the author do not care about the names of the classes. So I wonder <strong>how can I use those classes without specifying their names?</strong> </p>

<p><strong>Is this a kind of design pattern in c++ that I don't know?</strong></p>

<p>Thank you :)</p>

<hr>

<p>I want to add my guesses to make the question clear.</p>

<hr>

<p>My guesses:</p>

<p>The names of these classes are generated from __seed_, but when I search through the files, I can not find other references to __seed_, So I am sure The author did not use the names __seed_1, __seed_2 to create classes. (Actually the author said the the comments that she did not care about the names of the classes)</p>

<p>I also guessed that the author may have used those classes through the interface defined in the base class(virtual function). To do that, the author still needed to create these classes, but as I mentioned I could not find __seed_ in other parts of the code, So the author couldn't create classes, and therefore virtual function do not work either.</p>

<p>Actually, I tried remove these class definitions, and strangely the code compiles correctly. However, It lost some of functionalities, but It did not just core dump. It could still finish some tasks successfully <em>u</em></p>

<p>So, do anyone know:</p>

<ul>
<li>How can we use those classes without specifying their names?</li>
<li>Is this design a certain kind of design pattern?</li>
<li>In which situation should we define class without caring about their names?</li>
<li>As I mentioned, I removed some part of the code, and It compiled. How could this happen? I mean, Since I remove many classes from the source code, then If other parts of the code references those classes, the source can not compile. And If it compiles, Can I just conclude that those classes are not needed?</li>
</ul>

<p>ADDED:
As some of you recommended, 
the full source code is here: <a href="https://github.com/CryptDB/cryptdb/blob/master/main/rewrite_const.cc" rel="nofollow noreferrer">MIT Cryptdb</a>. In the file ./main/rewrite_const.cc, the author used macro ANON(lion 25) to define many classes without caring about their names.</p>

<p>Really appreciate your help :)</p>