warning :: Derived class hides the base class virtual function

We are porting from CC5.3 to CC5.8 compiler with Sun Studio one compiler. After plenty of hurdles we are in the final stage of removing the warning messages... Amoung the plenty the following one is very common and in different files. Why am I getting this error in 5.8 and not in 5.3 compiler....

Warning: derived_Object::markRead Hides the virtual function base_Object::markRead(ut_SourceCodeLocation&) const in a virtual base

From this it is easily understandable that the base class mark read was hidden by derived class markRead... when we drive and override the derived class function.... It is all over the place....

Thank you,

Saravanan Kannan

//public: using xx_Object :: markRead;

virtual void markRead() const;

[771 byte] By [Sara_Kan] at [2007-11-26 9:22:32]
# 1

The Sun C++ FAQ discusses the warning message:

http://developers.sun.com/prodtech/cc/documentation/ss11/mr/READMEs/c++_faq.htm l#Coding1

Notice that warnings are not necessarily errors. But I applaud your desire to fix the code so that it generates no warnings. I wish more of our customers could be persuaded to do the same. :-)

C++ 5.3 issues this warning, by the way. Example:

struct B { virtual int foo(int); };

struct D : B { virtual int foo(double); }; // line 2

D d;

line 2: Warning: D::foo hides the virtual function B::foo(int).

If for your particular code you do not see a warning with C++ 5.3, it would be due to a bug in C++ 5.3 that was later fixed.

clamage45 at 2007-7-6 23:55:58 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

Overriding is not the same as hiding.

[code]

class A {

public: virtual void do_something(int);

};

class B : public A {

public: virtual void do_something(int);

};

class C : public A {

public: virtual void do_something(double);

};

[/code](hey look, the code tag is working again, yay)

B overrides A's do_something, so there would be no warning.

C hides A's do_something, so there would be a warning. Add a using clause if you want to bring A's do_something into scope.

/lib

slashlib at 2007-7-6 23:55:58 > top of Java-index,Development Tools,Solaris and Linux Development Tools...