Why isn't this a POD type?

前端 未结 1 1168
情深已故
情深已故 2021-02-20 11:48

I ran the below with g++ -std=c++0x pod_test.cpp on g++ 4.6.2 (mingw). I get an error on A4. Why isn\'t A4 POD?

#include 
#include          


        
1条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-20 11:57

    It's not POD because it breaks this rule for standard layout classes:

    — either has no non-static data members in the most derived class and at most one base class with non-static data members, or has no base classes with non-static data members

    Only one class in the inheritance lattice can have non-static data members. In this case, both A and A4 have.

    0 讨论(0)
提交回复
热议问题