Re: inheritance question



Le samedi 17 mars 2007 18:50, Corey Konrad a écrit :
I am trying to figure out how inheritance works using the super method.
With the sample code below i get the error that i dont have enough
arguments for the constructor i dont understand why i am getting that
error.
[...]

Hi Corey,

I have read the questions you posted the last few days, and I would like to
give you a general counsel. It looks like you don't take care of the output
when an exception is raised. Though, the informations displayed when an error
occurs are very useful, and if you had paid attention to it, you would have
found your error immediatly.

For your particular problem, you can see this output :

/tmp/animal.rb:13:in `initialize': wrong number of arguments (1 for 2)
(ArgumentError)
from /tmp/animal.rb:13:in `initialize'
from /tmp/animal.rb:21:in `new'
from /tmp/animal.rb:21

If you don't already know, the first line means that at line 13 (line 13 is :
super(color)) a method was called with 1 argument instead of 2. This is
sufficient to start tracking down the error. The other lines represents the
call stack, ie the "path" which was followed to reach the exception.

And if there is an exception you don't understand, or that doesn't help you,
then join it with your code in your next message.

Happy learning :)

--
Olivier Renaud

.



Relevant Pages

  • Re: inheritance question
    ... On 3/17/07, Corey Konrad wrote: ... With the sample code below i get the error that i dont have enough ... arguments for the constructor i dont understand why i am getting that ...
    (comp.lang.ruby)
  • Re: directsound help
    ... >> At this point I can only suggest creating a brand new project file and ... > I just did a comparison the sample code had win32,_debug,_windows in its ... shoddy way because i still dont know what was wrong with it. ... still wouldnt work until I did the copy paste thing. ...
    (microsoft.public.win32.programmer.directx.audio)
  • Re: Problems editing System Registry entries created by another application
    ... I followed the sample code to setup RegistryPermissions and followed sample ... In the end I get another exception that states that the key in the key/vlaue ...
    (microsoft.public.dotnet.security)
  • Re: Vector and derived classes objects
    ... > wont be called for the objects the pointer points to, hence I dont see ... > any way an exception can be thrown there with my push_back. ... Josuttis as also mentiones that in his STL book. ...
    (comp.lang.cpp)
  • Re: Try/Catch
    ... Find my other post about the InnerException and sample code. ... It seems to work Ok without .tostring, and the exception is now ... aa is a UnauthorizedAccessException ...
    (microsoft.public.dotnet.languages.csharp)