M
mshetty
Hi,
I get an error "Warning: b::a_method hides the virtual function
a::a_method()."
on compiling the following code..
#include <iostream.h>
class a
{
public:
virtual int a_method ()
{
cout << "a::a_method" << endl;
return 0;
}
};
class b : public a
{
public:
int a_method (int x)
{
cout << "b::a_method" << endl;
return x;
}
};
class c : public a
{
public:
int a_method ()
{
cout << "c::a_method" << endl;
return 100;
}
};
int main()
{
b b_var;
b_var.a_method(10);
return 0;
}
The warning goes off if done the following:
Change class b : public a
to
class b : public virtual a
Have not been to understand the reason why the warning is removed as
"b::a_method still hides a::a_method()"
Would help if I could get some input.
Thanks and Regards,
M Shetty
I get an error "Warning: b::a_method hides the virtual function
a::a_method()."
on compiling the following code..
#include <iostream.h>
class a
{
public:
virtual int a_method ()
{
cout << "a::a_method" << endl;
return 0;
}
};
class b : public a
{
public:
int a_method (int x)
{
cout << "b::a_method" << endl;
return x;
}
};
class c : public a
{
public:
int a_method ()
{
cout << "c::a_method" << endl;
return 100;
}
};
int main()
{
b b_var;
b_var.a_method(10);
return 0;
}
The warning goes off if done the following:
Change class b : public a
to
class b : public virtual a
Have not been to understand the reason why the warning is removed as
"b::a_method still hides a::a_method()"
Would help if I could get some input.
Thanks and Regards,
M Shetty