fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class MyClass
  5. {
  6. public:
  7. constexpr MyClass()
  8. {
  9.  
  10. }
  11. };
  12.  
  13. class MyClass2
  14. {
  15. public:
  16. MyClass2()
  17. {
  18.  
  19. }
  20.  
  21. static constexpr MyClass myclass1; // error
  22. static constexpr MyClass myclass2 {}; // works
  23. };
  24.  
  25. static constexpr MyClass myclass3; // works
  26.  
  27. int main()
  28. {
  29. // your code goes here
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 3452KB
stdin
Standard input is empty
compilation info
prog.cpp:21:27: error: constexpr static data member 'myclass1' must have an initializer
  static constexpr MyClass myclass1; // error
                           ^
stdout
Standard output is empty