Click on image to see enlargment

PC-lint/FlexeLint Output | Reference Manual Explanation | Home

            bug1411.cpp

1    #include <stdio.h>
2
3    typedef const char * CS;
4    class Group
5        { public:
6        virtual CS noun(int good) const
7            { return good ? "good" : "bad"; }
8        };
9    class Women : public Group
10       { public:
11       CS noun(int good) const
12           { return good ? "motherhood" : "crime"; }
13       };
14   class Unions : public Group
15       { public:
16       CS noun(bool good) const
17           { return good ? "high wages" : "unemployment"; }
18       };
19   void speech( Group const *g )
20       {
21       printf( "I favor %s but I oppose %s\n",
22           g->noun(1), g->noun(0) );
23       }

A politician wants to specialize his speeches for different audiences. But he's getting strange results when speaking to Unions. What went wrong?


bug1411.cpp lint Output

--- Module:   bug1411.cpp (C++)
        _
        { return good ? "high wages" : "unemployment"; }
bug1411.cpp(17) : Warning 1411: Member with different signature hides virtual
    member 'Group::noun(int) const' (line 6)

    --- Wrap-up for Module: bug1411.cpp

Info 753: local class 'Women' (line 9, file bug1411.cpp) not referenced
Info 753: local class 'Unions' (line 14, file bug1411.cpp) not referenced


Reference Manual Explanation


1411   Member with different signature hides virtual member 'Symbol'
       (Location)  -- A member function has the same name as a virtual
       member of a derived class but it has a different signature
       (different parameter list).  This is legal but suspicious,
       because it looks as though the function would override the
       virtual function but doesn't.  You should either adjust the
       parameters of the member so that the signatures conform or choose
       a different name.  See also message 1511.


If you have comments or questions about this bug, please post them to our   Discussion Forum


Previous Bug - Bug #661 - February 2008

Use our Interactive Demo to Run FlexeLint on our Bugs of the Month

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright 2009, Gimpel Software, All rights reserved.