Board index » cppbuilder » Warning : xxx hides virtual function '_fastcall xxxxx

Warning : xxx hides virtual function '_fastcall xxxxx


2004-02-02 06:21:33 PM
cppbuilder109
I have derived from TStringGrid and what I'm trying to do is to
have my new grid take advantage of the OnSelectCell event.
How I want to use it is to have the component execute the user
defined OnSelectCell and based on the value of CanSelect, have
the component internally execute some code:
protected:
DYNAMIC void __fastcall SelectCell(int ACol, int ARow, bool &CanSelect);
//--------------------------------------------------------------
void __fastcall TFormulasGrid::SelectCell(int ACol, int ARow, bool &CanSelect)
{
inherited::SelectCell(ACol, ARow, CanSelect);
if( CanSelect )
{
// stuff
}
else
{
// other stuff
}
}
//--------------------------------------------------------------
The problem is that I get two warnings and one error:
[C++ Warning] TMGrid.h(63): W8022 '_fastcall TFormulasGrid::SelectCell(int,int,bool &)' hides virtual function '_fastcall TCustomDrawGrid::SelectCell(int,int)'
[C++ Warning] TMGrid.h(63): W8022 '_fastcall TFormulasGrid::SelectCell(int,int,bool &)' hides virtual function '_fastcall TCustomGrid::SelectCell(int,int)'
[C++ Error] TMGrid.cpp(273): E2227 Extra parameter in call to _fastcall TCustomDrawGrid::SelectCell(int,int)
The error points to the line:
inherited::SelectCell(ACol, ARow, CanSelect);
Can I do what I want? If so, how do I go about doing it?
~ JD
 
 

Re:Warning : xxx hides virtual function '_fastcall xxxxx

JD wrote:
Quote
DYNAMIC void __fastcall SelectCell(int ACol, int ARow, bool &CanSelect);
[C++ Warning] TMGrid.h(63): W8022 '_fastcall TFormulasGrid::SelectCell(int,int,bool &)' hides virtual function '_fastcall TCustomDrawGrid::SelectCell(int,int)'
[C++ Warning] TMGrid.h(63): W8022 '_fastcall TFormulasGrid::SelectCell(int,int,bool &)' hides virtual function '_fastcall TCustomGrid::SelectCell(int,int)'
[C++ Error] TMGrid.cpp(273): E2227 Extra parameter in call to _fastcall TCustomDrawGrid::SelectCell(int,int)
The virtual function SelectCell is declared as
virtual bool __fastcall SelectCell(int ACol, int ARow);
in TCustomGrid.
Your function doesn't match this declaration. You've added an extra
parameter so the compiler warns you that your function hides the
SelectCell from the base class. The error you get is coming from the
fact that there is no SelectCell(int,int,bool) in the base class so you
can't call it.
Michel
--
----------------------------------------
Michel Leunen
mailto: XXXX@XXXXX.COM
C++Builder, C++BuilderX, BCC5.5.1 Web site:
www.leunen.com/
----------------------------------------
 

Re:Warning : xxx hides virtual function '_fastcall xxxxx

"Michel Leunen" < XXXX@XXXXX.COM >wrote in message
Quote
Your function doesn't match this declaration. You've
added an extra parameter
You've also declared the method as DYNAMIC instead of 'virtual'. They are
not the same thing.
Gambit
 

{smallsort}

Re:Warning : xxx hides virtual function '_fastcall xxxxx

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
How I want to use it is to have the component execute the user
defined OnSelectCell and based on the value of CanSelect, have
the component internally execute some code:
Use this code instead:
protected:
virtual bool __fastcall SelectCell(int ACol, int ARow);
bool __fastcall TFormulasGrid::SelectCell(int ACol, int ARow)
{
bool CanSelect = inherited::SelectCell(ACol, ARow);
if( CanSelect )
{
// stuff
}
else
{
// other stuff
}
return CanSelect;
}
Gambit
 

Re:Warning : xxx hides virtual function '_fastcall xxxxx

"Remy Lebeau \(TeamB\)" < XXXX@XXXXX.COM >wrote:
Quote
Use this code instead:
Perfect - Thank you.
~ JD