Re: class and inheritance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alain Roger wrote:
Hi,

I'm trying to create a class that has as public members some other class
object.
for that i use almost the same syntax as under C# or C++.

header class:

<?php
class CARMainHeader
{
    // title of the main table header
    private $mTitle = null;

    // holds the height of the table header
    private $mHeight = null;

    // constructor
    public function __construct()
    {
        $this->mHeight = 15;
        $this->mTitle = "Title";
    }

    // set the title of the main table
    public function SetTitle($name)
    {
        $this->mTitle = $name;
    }

    // return the title of the main table
    public function GetTitle()
    {
        return $this->mTitle;
    }

    // set the height of the header
    public function SetHeight($height)
    {
        $this->mHeight = $height;
    }

    // return the height of the header
    public function GetHeight()
    {
        return $this->mHeight;
    }
}
?>


main class code :

<?php
include_once 'CARMainHeader.php';

class CARTable
{
    // holds the main table header object
    public $mTableHeader = null;

    // store the amount of columns in table
    private $mColumnsCount = null;

    // constructor
    public function __construct()
    {
        $this->mTableHeader = new CARMainHeader();
    }

    // rendering of table
    public function Render()
    {
        echo "<table>";
        echo "<tr />";
        echo "<td class=''>".$this->mTableHeader->;
you're missing something here, don't you think? :)
        echo "</td>";
        echo "<td class=''>";
        echo "</td>";
        echo "</table>";
    }
}
?>


in the CARTable, i'm not able in the Render function to write
$this->mTableHeader->GetTitle();
why ?

you can, and it works. Once you actually call that method.

- Tul

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux