What does "$this->A(); "" do ?(in constructor of class B)
does it make another instance of class A, and if not why do I have to parse vars to the A constructor ($this->A($var1,$var2))?.
I dont think that is what I want.
A can have many instances of B. B can have many instances of C.


                                                     A
B B B B
                     CCCC         CCCC      CCCC        CCCC

Should not a instanse(object) of class B bee able to request av var of the calling object (class A)?

Sorry about this stupid questions, I'm not a coder.
Thomas Munz wrote:
Use 'extends' syntax for sub classes

class A {
          var $some_var;
           var $class_B;
          function A(){
                $this->class_B = new B();
                $this->some_var=2;
          }
}

class B extends A {
          var $class_C;
          function B(){
                $this->A();
                $this->class_C = new C();
               //  $this->some_var= some_var_from_class_A; <-- $this->some_var 
contains the value allready
          }
}

class C extends A {
          function C(){
                $this->A();
                // $this->some_var= some_var_from_class_A; <-- $this->some_var 
contains the value allready
          }
}

on Friday 15 September 2006 11:01, Roger Helgesen wrote:
I have 3 classes, CLASS A,B and C

class A {
          var $some_var;
           var $class_B;
          function A(){
                $this->class_B = new B();
                $this->some_var=2;
          }
}

class B {
          var $some_var;
           var $class_C;
          function B(){
                $this->class_C = new C();
                $this->some_var= some_var_from_class_A;
          }
}

class C {
          var $some_var;

          function C(){
                $this->some_var= some_var_from_class_A;
          }
}



How can class B and C get the value of $some_var_class_A without using
"$this->class_B = new B($some_var);"


roger helgesen


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to