|
Author |
Topic: nested objects in processing OOP (Read 317 times) |
|
aceed
|
nested objects in processing OOP
« on: Mar 21st, 2004, 2:17am » |
|
hi I was trying to nest object in object, both of them belong to the same class, and one of arguments in constructor are this object dataType. Some example code below: Code: class Node{ Node a,b,parent; float xdir; void Node(Node _parent,float xDir){ parent=_parent; xdir=xDir; } private void xclone(){ // two nested objects a=new Node(this,1); b=new Node(this,-1); } } |
| I this case, I've got message: "Perhaps you wanted the overloaded version "Node()"... interesting? For example in Flash AS2 this kind of coding is possible.
|
« Last Edit: Mar 21st, 2004, 2:22am by aceed » |
|
|
|
|
arielm
|
Re: nested objects in processing OOP
« Reply #1 on: Mar 21st, 2004, 3:07am » |
|
q: why do you need to have "void" in your constructor?
|
Ariel Malka | www.chronotext.org
|
|
|
Mythmon
|
Re: nested objects in processing OOP
« Reply #2 on: Mar 21st, 2004, 7:56am » |
|
actually, ive found that if you have a void before your contructer then it doesnt act as a contructer also, what is htere at the moment will give you infinite amounts of nesting, which p5 probaly wont like...
|
|
|
|
der_rabe
|
Re: nested objects in processing OOP
« Reply #3 on: Mar 21st, 2004, 11:08am » |
|
constructors must have no return type in their declaration. otherwise it isn't handled as an constructor. So, when you try to create a new object from your class with Node(), java looks for a constructor with this name, but cannot find one. But it finds a method called Node(). That might be the reason for the message of the "compiler".
|
Bernd Salewski student of digital media Hochschule Bremen
|
|
|
aceed
|
Re: nested objects in processing OOP
« Reply #4 on: Mar 22nd, 2004, 4:21am » |
|
thank you very much, it's strange to me coding in processing (relative to flash, PHP, or JS). Mythmon - don't worry about infinity nesting, see in my example. http://aceed.mlociny.waw.pl/pro/samples/3dtree/ forgive me, its my first code in processing regards jarek muras vel aceed
|
« Last Edit: Mar 22nd, 2004, 4:24am by aceed » |
|
|
|
|
|