As pointed out, classes are not allocated anywhere. Objects, which are instances of an anonymous class can be allocated in several ways:
For example as subobjects of another object:
struct S
{
struct {
int x, y;
} p;
};
or together with the class definition
struct
{
float x, y;
} p;
or using decltype
:
struct S
{
struct {
int x, y;
} p;
};
void g (decltype (S::p)) {}
decltype (S::p) *f ()
{
auto p = new decltype (S::p);
g(*p);
return p;
}