Re: compiler error
From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: Sun, 15 Feb 2004 01:11:29 +0000
In message <firstname.lastname@example.org>, Robert W Hand
>On Sat, 14 Feb 2004 21:54:47 +0000 (UTC), "Jason"
>>int a, b, c;
>>//place values in a,b,c using atoi
read his code, specifically the comment above.
>>x.func(a, b, c);
>>And the compiler says this:
>>no matching function for call to 'XClass::func(int&, int&, int&)
>>candidates are: int XClass::func(int, int, int);
>>What might have gone wrong?
>>Clearly I have declared a,b,c ok and not done much with them except set them
>>to certain values. Why would the compiler complain that I am calling the
>>function using references when I am not?
>It is undefined behavior.
He said he had omitted the initialisation code. Anyway even if he
actually left it out, the compiler would not do what he reports.
> Automatic variables that are not
>initialized have indeterminant values. You are not allowed to assign
>their values to other variables. But you can assign the objects a, b,
>c to references to int without specifying values for a, b, c. So it
>may be that your compiler has noted the undefined behavior and warned
>you about it.
>Perhaps someone will have a better idea.
-- Francis Glassborow ACCU Author of 'You Can Do It!' see http://www.spellen.org/youcandoit For project ideas and contributions: http://www.spellen.org/youcandoit/projects