Forward declare typedef within C++ class

前端 未结 5 710
长发绾君心
长发绾君心 2021-02-04 06:56

What\'s the best solution to forward declare a typedef within a class. Here\'s an example of what I need to solve:

class A;
class B;

class A
{
    typedef boos         


        
5条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 07:31

    As others have noted, you cannot forward-declare typedefs. That's in part because typedefs aren't really "types" of their own, but aliases for other types (hence the C++11 equivalent notion of a "type alias" such as "using Int = int;"). That means, for example, that typedefs don't show up in ABI elements such as mangled names, and so the compiler really has to know enough of the underlying type to satisfy all ABI requirements (including how to mangle the type name).

提交回复
热议问题