BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Warning : xxx hides virtual function '_fastcall xxxxx

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
JD
Guest





PostPosted: Mon Feb 02, 2004 10:21 am    Post subject: Warning : xxx hides virtual function '_fastcall xxxxx Reply with quote




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

Back to top
Michel Leunen
Guest





PostPosted: Mon Feb 02, 2004 11:05 am    Post subject: Re: Warning : xxx hides virtual function '_fastcall xxxxx Reply with quote



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:michel (AT) leunen (DOT) com
C++Builder, C++BuilderX, BCC5.5.1 Web site:
http://www.leunen.com/
----------------------------------------

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Feb 02, 2004 7:11 pm    Post subject: Re: Warning : xxx hides virtual function '_fastcall xxxxx Reply with quote




"Michel Leunen" <mleu (AT) STOPSPAMskynet (DOT) be> wrote


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



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Feb 02, 2004 7:13 pm    Post subject: Re: Warning : xxx hides virtual function '_fastcall xxxxx Reply with quote


"JD" <nospam (AT) nospam (DOT) com> wrote


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



Back to top
JD
Guest





PostPosted: Mon Feb 02, 2004 8:21 pm    Post subject: Re: Warning : xxx hides virtual function '_fastcall xxxxx Reply with quote


"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote:
Quote:
Use this code instead:

Perfect - Thank you.

~ JD


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.