How to add constructors/destructors to an unnamed class?

后端 未结 3 962
广开言路
广开言路 2020-12-02 20:27

Is there a way to declare a constructor or a destructor in an unnamed class? Consider the following

void f()
{
    struct {
        // some implementation
          


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 20:36

    You can not declare a constructor or destructor for an unnamed class because the constructor and destructor names need to match the class name. In your example, the unnamed class is local. It has no linkage so neither mangled name is created.

提交回复
热议问题