| Last Modified On : | December 14, 2008 3:33 PM PST |
Rate |
|
Compiler encounters code in which one entity is hidden by another, this results in being no use of first entity.
The following sample generates Warning 1125 :
class Base{
public :
virtual void foo (float f){ }
};
class Derived : public Base {
public :
void foo (char c) { }
};
void foobar ()
{
Derived d;
char c1 = 'c';
float f1 = 46.68;
d.foo (c1); // Derived is called
d.foo (f1); // Derived is called even though argument is float. Base class function gets hidden
}
>> icl /c t.cpp
Intel(R) C++ Compiler Professional for applications running on IA-32, Version 1
1.0 Build 20080930 Package ID: w_cproc_p_11.0.061
Copyright (C) 1985-2008 Intel Corporation. All rights reserved. t.cpp
t.cpp(8): warning #1125: function "Base::foo(float)" is hidden by "Derived::foo"
-- virtual function override intended?
void foo (char c) { }
^
Default type of this diagnostic is Warning
Unhide the base function by:
The "class Derived" should be:
class Derived : public Base {
public :
using Base::foo;
void foo (char c) { }
};

English | 中文 | Русский | Français
Grishma Kotecha (Intel)
| ||
Jennifer Jiang (Intel)
|