« Return to Thread: rename and redefine with an attribute and a method

rename and redefine with an attribute and a method

by panfriedwoggle :: Rate this Message:

Reply to Author | View in Thread

Hi all,

I've been banging my head against this for hours and am now at a loss.

I have:

class A
...
feature
    c: INTEGER
...
end -- A

I want to replace this attribute c in a subclass with a method:

class B

inherit
    A
        rename
            c as c_int -- so all the features that manipulate c in the
superclass still work fine when inherited, and I can get at it too
        redefine
            c -- because I want to redefine it here
        end
...
feature
    my_other_A: A
    c: INTEGER is
        do
            result := c_int + my_other_A.c
        end -- c
end -- B

I cannot get this to work. First, if I included the redefine clause in
B as above it won't compile - fair enough, I have renamed c, so it's
not around for me to redefine. I can just give a new definition for c,
I would think...

... but no. After removing the redefine clause, everything compiles
sweetly, but it does not work. Using the debugger, it seems that
routine c is never entered for objects of class B. It is just
returning the integer that I renamed c_int.

Surely there is a way of overriding an attribute with a method? Isn't
Eiffel supposed to have a Uniform Access Principle?

I am at a loss...

Thanks,

David


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/eiffel_software/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/eiffel_software/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:eiffel_software-digest@...
    mailto:eiffel_software-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    eiffel_software-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

 « Return to Thread: rename and redefine with an attribute and a method

LightInTheBox - Buy quality products at wholesale price