🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by franco@olsen.UUC Fri, 03 Mar 1989 18:36
Smalltalk-80 like inheritance in C++ possible ?
#2689
Author: franco@olsen.UUC
Date: Fri, 03 Mar 1989 18:36
83 lines
1618 bytes


Hi,

Allow me a question which may be trivial for you guys. I'm a
beginner of C++ and therefore interested in the following
flavour of inheritance:

    In Smalltalk-80 you can use inheritance as in this sample program:

    (***********************************)

    class name       One
    superclass       Object
    instance methods

	test
	    ^1

	result1
	    ^self test


    class name       Two
    superclass       One
    instance methods

	test
	    ^2


    class name       Three
    superclass       Two
    instance methods

	result2
	    ^self  result1
	result3
	    ^super test


   (*************************************)

   Now create new instances:

    example1 <- One new
    example2 <- Two new
    example3 <- Three new

    and consider scenarios like this:

    expression           result
    ----------           ------

    example1 test          1
    example1 result1       1
    example2 test          2
    example2 result1       2
    example3 test          2
    example3 result2       2
    example3 result3       2



    Now comes the tricky part: How can I translate the behavior of
    the code outline above to the appropiate structures in C++ ?
    How do you move *up and down* in a given class hierarchy,
    like in my little example, using C++ ?

    Is it possible to cover this examples with an easy to understand and well
    structured program in C++, how is this best done ?

    Could anybody give me a pointer ?

    Thanx

    Franco M. Monti
    Olsen & Associates
    Seefeldstr. 233
    8008 Zuerich

    Switzerland
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads