why a derived class with virtual base classes can not have constexpr constructors?

ma guangzhi 6 Reputation points
2022-02-03T02:19:08.173+00:00

This question is about error E2403 generated by Visual stuidio 2019 C++.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,520 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. YujianYao-MSFT 4,271 Reputation points Microsoft Vendor
    2022-02-03T03:38:38.867+00:00

    Hi @ma guangzhi ,

    I recommend that you read this documentation, which states:

    It can't be virtual. A constructor can't be defined as constexpr when the enclosing class has any virtual base classes.

    Best regards,

    Elya


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.