Can a member of a class be declared with another class, and this function is required for the assignment of this member?
Class A
{
var $sun = ';
var $sav = false;
}
Class B
{
var $vo = A;
var $tmp = 0;
}
Isn't that right?
That way: Class B
{
var $vo;
var $tmp = 0;
function f ()
{
$this->vo = new A;
}
}
In use:
$cls = new B;
$cls->vo->tmp = 1; Can't you do that, too? Do you use the function of a class member?
Share to:
------Solution--------------------
$cls = new B;
$cls->f ();//Because your VO attribute is assigned in this method!
$cls->vo->tmp = 1;
------Solution--------------------
Class B
{
var $vo = A;It's not right here!
var $tmp = 0;
}
------Solution--------------------
Reference:
Quote: Reference:
$cls = new B;
$cls->f ();//Because your VO attribute is assigned in this method!
$cls->vo->tmp = 1;
$cls->vo->tmp = 1; I'm testing this assignment as if it's not possible.
Your code estimates are wrong to write.
The following code is the same as your logic, and executes as expected.
Class A {}
Class B {
var $attrV;
function SETATTRV ()
{
$this->ATTRV = new A ();
}
}
$obj _b = new B ();
$obj _B->SETATTRV ();
$obj _b->attrv->attra = ' A ';
Echo ' $obj _b->attrv->attra= '. $obj _b->attrv->attra;