Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
final means "final"
#6
Are you sure A10-3-3 requires functions to be marked "final"? We've seen before that sometimes the examples do not match (or even contradict) the rule text (e.g. A3-1-5).

A10-3-3 says: "Virtual functions shall not be introduced in a final class".

Some definitions of introduce that I can find:

"to put something into use, operation, or a place for the first time" (link)
"to mention something for the first time in a piece of writing" (link)

In my view, adding an override function in a Derived class is not introducing a virtual function, since it's not the first time it appears (it did in the Base class).

Going to the original source, HIC v4.0 Rule 9.1.5, the rule is clear - do not add new virtual functions in a final class, since there won't be any further derived classes that can benefit from it. 

Code:
class Base
{
public:
   virtual void f1();
};

class Derived final : public Base
{
public:
   virtual void f2();  // Do not introduce a new virtual function!
}

Otherwise, A10-3-2 has no purpose at all, right?
Reply


Messages In This Thread
final means "final" - by kent.dorfman766 - 14-03-2022, 06:18 PM
RE: final means "final" - by cgpzs - 15-03-2022, 01:57 PM
RE: final means "final" - by kent.dorfman766 - 18-03-2022, 05:01 AM
RE: final means "final" - by cgpzs - 21-03-2022, 10:31 AM
RE: final means "final" - by misra cpp - 22-03-2022, 11:00 AM
RE: final means "final" - by cgpzs - 22-03-2022, 04:03 PM
RE: final means "final" - by misra cpp - 13-05-2022, 01:56 PM
RE: final means "final" - by novelsmith - 23-01-2024, 07:51 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)