On Wed, 23 Jul 2003 09:33:24 -0400, Victor Bazarov wrote:
"ken" <ke*@gandalf.foskey.org> wrote...
OK now I can actually see something that might be the problem, the class I
am using is derived from List
class List : private Container
{
public:
using Container::Insert;
using Container::Replace;
using Container::Clear;
using Container::GetCurObject;
using Container::GetCurPos;
using Container::GetObject;
using Container::GetPos;
using Container::Seek;
using Container::First;
using Container::Last;
using Container::Next;
using Container::Prev;
using Container::Remove;
So the Remove is declare private by inheritance above but the using
statement is supposed to override the private to public.
Correct. It creates aliases for the names in 'using' declarations.
Those aliases are in 'public' area, so they are public for 'List'.
I added the
"using" clause at someones suggestion but it did not make any difference,
with or without the using clause.
It depends on what difference you thought it would make.
The actual class where it is trying to be used we are seeing:
class INetContentTypeParameterList: private List
So if it is using inheritance then it should fail, but the using clause
should make that specific routine public. Is this right or wrong?
Is what right or wront? 'List' is a private base class of 'INet...List'.
All its members, including the aliases you added to 'List' with 'using'
declarations, are private to the outside of 'INet...List'. However,
they should be visible (accessible) in the members of 'INet...List' class.
Example:
class Bottom {
public:
void foo();
protected:
void bar();
};
class Middle : private Bottom {
public:
using Bottom::bar(); // 'Middle::bar' is public
};
class Top : private Middle {
void member();
};
void Top::member() {
bar(); // this is OK -- Middle::bar is accessible here
}
int main() {
Top top;
top.bar(); // error -- anything from Middle is private
// if accessed through Top object
Middle middle;
middle.bar(); // OK -- Middle::bar is public
}
Victor
So going back to my original code:
void INetContentTypeParameterList::Clear()
{
while (Count() > 0)
delete static_cast< INetContentTypeParameter * >(this->Remove(Count() - 1));
}
The Remove call is public from list which is in turn inherited as private
intoINetContentTypeParameterList so any routine within
INetContentTypeParameterList should be able to use Remove without any conflict.
So in this case should the compiler find the inheritance of Remove from
list and not need the explicit "this->" pointer? If I remove "this->" the
compiler is giving:
/data2/office/tools/source/fsys/dirent.cxx:347: error: cannot call member
function `??? Container::Remove()' without object
Is this a bug with gcc 3.3.1 or something else?
Ta
KenF
PS: Does anyone have a web link on the using clause searching for a
common word such as using does not work very well.