could someone tell me how this exactly works?
what happens if you put it in your code? what happens if you place code before or after it?
I do have an idea what it does but im not sure
super.function();
-
- Average
- Posts: 61
- Joined: Thu Jun 03, 2010 3:53 pm
Re: super.function();
From what I can tell, it calls the function as it is defined in the superclass.
It's basically there so you can add code to a function without needing to rewrite what was already defined in the superclass.
It's basically there so you can add code to a function without needing to rewrite what was already defined in the superclass.
Re: super.function();
yes I thought so.
But I want to know exactly hoe it works.
if you place code before super.function();. will it first call the code ,and then the code of the superclass?
or does it mean that the code replaces the code of the superclass?
But I want to know exactly hoe it works.
if you place code before super.function();. will it first call the code ,and then the code of the superclass?
or does it mean that the code replaces the code of the superclass?
-
- Average
- Posts: 61
- Joined: Thu Jun 03, 2010 3:53 pm
Re: super.function();
I'm sure it's treated as a normal function, so it will be called in the order you have it.
Super.function() is there just so you don't have to copy/paste the super function into your class, give it a name and then call that instead.
Super.function() is there just so you don't have to copy/paste the super function into your class, give it a name and then call that instead.
Re: super.function();
one more question
if you use local properties in a function.
will they also travel to the childclass function if it calls super.function(); ?
if you use local properties in a function.
will they also travel to the childclass function if it calls super.function(); ?
-
- Average
- Posts: 61
- Joined: Thu Jun 03, 2010 3:53 pm
Re: super.function();
Hmm, for that I have no idea. I don't really code much o_O
The best way to find out would be to make a test package with two scripts, and test it that way.
The best way to find out would be to make a test package with two scripts, and test it that way.
Re: super.function();
I think it's a good idea to read about scope in programming, it's one of the basics you need to know. I don't know the specifics about UScript, but I'm almost positive that variables or references with a local identifier have local scope. This means that you can't use the variable or reference outside the function (or block, depending on the language) it's declared in.
- Programming Scope
- Local Scope
- Programming Scope
- Local Scope
Re: super.function();
Your question isn't really unrealscript related. Calling a super function is possible in all object oriented languages. I'd strongly recommend reading a book (or a tutorial) about object oriented programming (or perhaps java which is similar to unrealscript in many ways and a very popular OO language). And as Bloeb says, local variables are only valid in the scope in which they were defined. This means that if you call a super function, its local variables will only exist in the scope of that super function. They will not be valid in the scope of the function that called the super function.