Jump to content


Photo

Using a class inside another class


  • Please log in to reply
1 reply to this topic

#1 fogeytron

fogeytron
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 10 April 2006 - 03:24 AM

Hello there,

This is not my exact code, just the general idea.

class.c.inc
------------------
class C
{
.
.
.
}

-------------------
include 'class.c.inc';
class A
{
var $b = new C();
.
.
.
}

error

Parse error: parse error in /Users/jonathan/fogeytron_be/www/DNS/class.zonefile.inc on line 9

Where line 9 is var $b = new C();.

I have not seen any code that attempts this. I have done it in C++. It seems rather basic. So I think I am calling it incorrectly.

Please help?

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 10 April 2006 - 02:01 PM

You need to assign it within the construct. (I assume your using php4)
include 'class.c.inc';
class A
{
var $b;

function A() {
  $this->b = new C();
}
.
.
.
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users