
-----------------------------------
illu45
Sat Mar 05, 2005 10:39 pm

Inherting Classes
-----------------------------------
Hello all,

I am having some trouble with classes and inheritance... I have a clas (let's call it 'basic'), and it is located in a file (say basic.t). I then want to inherit this class in another file (say main.t), however, when I try to do so, I get errors with it not being in main.t's scope, or declaration errors... 

Does anyone have some advice on how I would go about ibheriting basic in another file?

Any help would be greatly appretiated,
illu45

-----------------------------------
Bacchus
Sat Mar 05, 2005 10:52 pm


-----------------------------------
include ""  prettu sure theres a tutorial on it too

-----------------------------------
Cervantes
Sun Mar 06, 2005 8:17 am


-----------------------------------
Bacchus: Include is not what he's looking for.  He's looking for a way to make one class inherit all the procedures and functions of a previously built class.  If you try to include the other file, it's the same as copying and pasting all the code inside the Basic.t file inside the main class.  So it would look like this:

class main
    export stuff
    class basic
        export ...
    end class
end class

That won't work, as you'll get the "Classes may only be declared at the program, monitor, or module level."

illu45: I could be wrong, but I think this will help you:

An inheritItem is one of:

  (a) id 
  (b) id in fileName 


The second form is used when the inherit clause is for a separate unit and the imported item is in a file whose name is different from the item's name, for example:


        inherit ledger in "newledg.t"
The fileName must be an explicit character string, e.g., "newledg.t". Parentheses are allowed around the item in an inherit clause, as in:

        inherit ( ledger in "newledg.t" )

So, make Basic.t into a unit it and save it as Basic.tu.  Then use inherit in fileName.
Hope that helps,
-Cervantes

-----------------------------------
Bacchus
Sun Mar 06, 2005 8:48 am


-----------------------------------
ok then, wasnt sur4e wat they meant guess i was wrong lol

-----------------------------------
illu45
Sun Mar 06, 2005 9:58 am


-----------------------------------
I tried renaming the basic.t into basic.tu (adding unit to it), and theninheriting it into main.t, however, I get 'basic has not been declared'. If I try to import "basic.tu" then I get Cannot inherit symbol 'basic' unless it is in the same scope...
