fork download
  1. struct Banana
  2. {
  3. Banana () {}
  4. Banana (float) {}
  5.  
  6. virtual Banana CreateByHalfLength(float halfLength) final {
  7. return Banana::CreateByHalfLengthImpl(halfLength);
  8. }
  9.  
  10. static Banana CreateByHalfLengthImpl(float halfLength) {
  11. return Banana(halfLength * 2);
  12. }
  13. };
  14.  
  15. struct AdvancedBanana : Banana
  16. {
  17. static Banana CreateByHalfLength(float halfLength) { // Error
  18. return Banana(halfLength * 2);
  19. }
  20. };
  21.  
  22. int main ()
  23. {
  24. }
  25.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:17: error: 'static Banana AdvancedBanana::CreateByHalfLength(float)' cannot be declared
   static Banana CreateByHalfLength(float halfLength) {  // Error
                 ^
prog.cpp:6:18: error:   since 'virtual Banana Banana::CreateByHalfLength(float)' declared in base class
   virtual Banana CreateByHalfLength(float halfLength) final  {
                  ^
stdout
Standard output is empty