[Bug 78641] New: code completion: overloaded members in derived classes not hidden when redefined

Daniel Franke daniel.franke at imbs.uni-luebeck.de
Sun Mar 28 21:42:07 UTC 2004


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
      
http://bugs.kde.org/show_bug.cgi?id=78641      
           Summary: code completion: overloaded members in derived classes
                    not hidden when redefined
           Product: kdevelop
           Version: 3.0.2
          Platform: unspecified
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: kdevelop-devel kdevelop org
        ReportedBy: daniel.franke imbs uni-luebeck de


Version:           3.0.2 (using KDE 3.2.1, compiled sources)
Compiler:          gcc version 3.3.1 (SuSE Linux)
OS:          Linux (i686) release 2.4.21-99-default

Daniel:

Assume two simple classes (stripped down example):
--
class A {
public:
      void print(const string& t) { print(t.c_str()); }
      virtual void print(const char *s) { cout << "A: " << s; }
};

class B : public A {
public:
      void print(const char *s) { cout << "B: " << s; }
};
--

and a short code snipplet:

--
string hello = "Hello";
A *a = new B;
a->[ctrl+space]
--
Here code completion offers both print-methods, therefore:
--
string hello = "Hello";
A *a = new B;
a->print(hello)
--
As expected, gcc compiles the code, "Hello" is printed at stdout.

A small change:
--
string hello = "Hello";
B *b = new B;
b->[ctrl+space]
--
Again, code completion offers both print methods.
--
string hello = "Hello";
B *b = new B;
b->print(hello);
--
gcc complains:
--
home/daniel/cvs/test/src/test.cpp: In function `int main(int, char**)':
/home/daniel/cvs/test/src/test.cpp:51: error: no matching function for
call to `B::print(std::string)'
/home/daniel/cvs/test/src/test.cpp:42: error: candidates are: virtual void
B::print(const char*)

----
Jens Dagerbo wrote (kdevelop-devel):

Quoting Eckel:
"If a base class has a function name that's overloaded several times, 
redefining that function name in the derived class will hide _all_ the 
base-class versions."

I don't think this is the worst bug in the CC mechanism, but it is incorrect 
and should probably be reported. ;)




More information about the KDevelop-devel mailing list