|
-
November 10th, 2008, 01:22 AM
#1
strange error!
I will give out snippets of the production level code in my current project (regardless of the legal, moral, ethical, mathematical and political correctness of doing so).
The is a class having a function:
Code:
class bu_tde_mti_base:public some_class
{
...
public:
virtual inline void
set( const bu_mti_typ_e mti_typ )
}
bu_mti_typ_e is an enum type.
There is another class:
Code:
class bu_tde_mti : public bu_tde_mti_base
{
...
}
The there is some code:
Code:
bool
if_cup_intf::build_fld_070( some params,
const bu_tde_mti &mti,
more params)
{
...
mti.set( mti_netwk_mgmt_rqst_resp );
}
This code is getting the following error:
Code:
Could not find match for bu_tde_mti_base::set(bu_mti_typ_e mti_typ) needed in function
if_cup_intf::build_fld_070(…)
Two of us senior programmmers have tried doing something about it, to no avail. So definitely I would like help in solving this error.
But even before we start, can someone explain to me how the compiler pinpoints the exact level in the three-level hierarchy where it is expecting the function? It's denitely not psychic???
We are trying to compile this in a Sun box.
$uname -a
SunOS oma3s016 5.10 Generic_120011-14 sun4u sparc SUNW,Sun-Fire-880
$
the compiler is SunWSPro CC.
PLEAAASE HELP!
---------------------
I tried casting the parameter of the call to a const since I saw the const missing from what the compiler is trying to look for. This time it gave the same error but for a formal parameter of "const int". And what more, the set function IS overloaded for a const int formal argument..
Last edited by indrajit_p1; November 10th, 2008 at 01:26 AM.
Reason: Additional points
-
November 10th, 2008, 02:07 AM
#2
Re: strange error!
Does bu_tde_mti override the set method with a const int argument ?
If so - you need to override the set method with const bu_mti_typ_e mti_typ argument in bu_tde_mti as well, otherwise the compiler will only consider the overridden int argument method.
Defining a method with the same name hides the base class implementation. It doesn't matter whether the function signature is different.
Regards,
Zachm
-
November 10th, 2008, 02:55 AM
#3
Re: strange error!
No!
there are no set functions in bu_tde_mti at all. All the overloaded set functions co-exist in bu_tde_mti_base.
I
-
November 10th, 2008, 07:28 AM
#4
Re: strange error!
mti is a const reference there. set() is a non-const function.
-
November 10th, 2008, 07:44 AM
#5
Re: strange error!
perfect!!
don't feel like thinking of the solution after a long and heavily loaded day at office. and this is urgent.
will deeply appriciate any help with that Lindley..
-
November 10th, 2008, 08:19 AM
#6
Re: strange error!
Aside from making mti a non-const reference, I can't offer any advice, as I know nothing about the logical context in which this all occurs.
-
November 10th, 2008, 08:24 AM
#7
Re: strange error!
To expant on Lindley's 100% correct post.
1) You have told the compiler that build_fld_070 MUST NO MODIFY the mti parameter.
2) You have then proveded to tell the compiler to MODIFY mti (by calling the set...)
STOP TELLING COMPILER CONFLICTING INFORMATION!!!!!!!...right now it is simply refusing to accept your CONFLICTING instructions.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
November 11th, 2008, 12:49 AM
#8
Re: strange error!
Guru's thanks a TON for the help. I think I have a way to bypass the particular constness problem. so (with u'r help) that front is handled.
but note one point..the compiler never complained about the constness of the reference/object in the first place.
I did another small experiment yesterday - I called a public const function of the same bu_tde_mti_base class from the same reference, and it seemed not to find that function either, giving the same error message for this other function that I called to test.
:-O
I
-
November 11th, 2008, 02:53 AM
#9
Re: strange error!
Hi all,
The non-const workaround (which was a legally, morally, ethically [and in the light of the const problem, mathematically (I don't know about politics)] justified way of doing things) WORKED!
Thanks everyone.
:-)
I
p.s.: the compiler writer should be sued
-
November 11th, 2008, 05:26 AM
#10
Re: strange error!
 Originally Posted by indrajit_p1
p.s.: the compiler writer should be sued
Why? What evidence do you have that the compiler is wrong?
Regards,
Paul McKenzie
-
November 11th, 2008, 08:09 AM
#11
Re: strange error!
The error message says that it's not finding a match for the function while the match IS there. Should it rather not have made it clearer that a non-const function is being called on a const object (reference..whatever..)??
I
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|