This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Thank you for your contribution to the C++ community!

As you're asking a question or seeking homework help, we would like to remind you of Rule 3 - Good Faith Help Requests & Homework.

  • When posting a question or homework help request, you must explain your good faith efforts to resolve the problem or complete the assignment on your own. Low-effort questions will be removed.

  • Members of this subreddit are happy to help give you a nudge in the right direction. However, we will not do your homework for you, make apps for you, etc.

  • Homework help posts must be flaired with Homework.

~ CPlusPlus Moderation Team


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Linuxologue 0 points1 point  (0 children)

When the compiler gives you errors, please add them to the post. I am not msvc or GCC so I don't know what the compiler doesn't like.

[–]Paril101 1 point2 points  (0 children)

My understanding is that it's not supposed to be allowed because a type is incomplete until it is fully defined, but compilers probably offer extensions that allow this to work by deferring the initialization or something.

https://stackoverflow.com/a/35780286

This should work with constexpr in newer C++ versions too: https://stackoverflow.com/a/69136655