🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by David Eppstein Sat, 06 May 1989 20:20
stupid warning
#1951
Author: David Eppstein
Date: Sat, 06 May 1989 20:20
32 lines
1652 bytes
G++ warns me when a derived class has a member function that shadows
(with different type) a member of an ancestor class.  So far so good.
But it warns even when the shadowed member is private, and therefore
totally invisible to the derived class!
If it's invisible, why should I care that it has the same name?

Replies by mail please, I don't read gnu.g++.bug.

    ------------ sample code illustrating the bug ------------
class foo {
   int state;
 public:
    foo() { state = 1; }
    int baz() { return state; }
};
class bar : public foo { public: int state() { return baz(); } };

    ------------ output from g++ run on the sample ------------
g++ version 1.32.0
 /usr/local/gnu/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dvax -Dunix test.c /tmp/cc026501.cpp
GNU CPP version 1.33
 /usr/local/gnu/lib/gcc-c++ /tmp/cc026501.cpp -quiet -dumpbase test.c -version -o /tmp/cc026501.s
GNU C++ version 1.32.0 (vax) compiled by GNU C version 1.33.
In function bar::state ():
test.c:7: warning: shadowing member `state' with member function
 as /tmp/cc026501.s -o test.o
 /usr/local/gnu/lib/gcc-ld++ -C /usr/local/gnu/lib/crt0+.o test.o -lg++ /usr/local/gnu/lib/gcc-gnulib -lc
Undefined symbols:
 _main

-- 
David Eppstein  eppstein@garfield.cs.columbia.edu  Columbia U. Computer Science
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads