Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Inherting Classes
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
illu45




PostPosted: Sat Mar 05, 2005 10:39 pm   Post subject: 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
Sponsor
Sponsor
Sponsor
sponsor
Bacchus




PostPosted: Sat Mar 05, 2005 10:52 pm   Post subject: (No subject)

include "" prettu sure theres a tutorial on it too
Cervantes




PostPosted: Sun Mar 06, 2005 8:17 am   Post subject: (No subject)

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:
code:

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:
Turing Reference wrote:

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




PostPosted: Sun Mar 06, 2005 8:48 am   Post subject: (No subject)

ok then, wasnt sur4e wat they meant guess i was wrong lol
illu45




PostPosted: Sun Mar 06, 2005 9:58 am   Post subject: (No subject)

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...
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: