Project

General

Profile

Design #1625

Use new C++ keyword override

Added by John Abbott over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Safety
Target version:
Start date:
25 Oct 2021
Due date:
% Done:

100%

Estimated time:
12.50 h
Spent time:

Description

Scott Meyers, in Effective Modern C++, writes in Item 12 that one should use the new C++ keyword override for member function in derived classes which override ones declared in a base class.

It does not make the code faster, but does help highlight mistakes (and could be useful if we want to change a function interface).

CoCoALib uses inheritance quite a lot, so probably many changes are needed.


Related issues

Related to CoCoALib - Design #1225: Move to C++14 (skipping C++11)In Progress2018-09-06

History

#1 Updated by John Abbott over 2 years ago

  • Related to Design #1225: Move to C++14 (skipping C++11) added

#2 Updated by John Abbott over 2 years ago

  • % Done changed from 0 to 50

I think I have made most of the changes... quite a mind-numbing experience :-(

I may have found a couple of typos (presumably harmless as everything seemed to work OK beforehand).

There were quite a lot of using commands inside various class declarations; with a comment about avoiding a compiler warning about overloading.
I have commented these commands out, and everything compiles fine on my linux box (g++ 7.5.0)
Why were they put in? And when?

@Anna: does your compiler need them?

#3 Updated by John Abbott over 2 years ago

In FractionField.C I have found this check-in comment:

// Revision 1.32  2014/05/14 15:57:15  bigatti
// -- added "using" for clang with superpedantic flag

I suppose this was the cause.
Anna: can you check the current situation?
Maybe comment out the using commands on lines 178 and 179; then try compiling with "superpedantic" flag.

#4 Updated by Anna Maria Bigatti over 2 years ago

John Abbott wrote:

In FractionField.C I have found this check-in comment:
[...]

I suppose this was the cause.
Anna: can you check the current situation?
Maybe comment out the using commands on lines 178 and 179; then try compiling with "superpedantic" flag.

this is what I (still) get:

Compiling FractionField.o
FractionField.C:178:15: error: ISO C++11 does not allow access declarations; use
      using declarations instead
    RingBase::myNew;
              ^
    using 
FractionField.C:179:15: error: ISO C++11 does not allow access declarations; use
      using declarations instead
    RingBase::myAssign;
              ^
    using 
2 errors generated.

#5 Updated by John Abbott over 2 years ago

  • Status changed from New to Resolved
  • Assignee set to John Abbott
  • % Done changed from 50 to 80

I have checked in (and found several errors/inconsistencies while doing so).
All compiles and works fine on my Linux box.

#6 Updated by John Abbott about 2 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 80 to 100
  • Estimated time set to 12.50 h

No one has howled in the last 3 months, so closing.
Maybe on the next trip to Genoa I can check on Anna's computer.

Also available in: Atom PDF