Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2009
    Posts
    143
    Thanks
    14
    Thanked 1 Time in 1 Post

    class inheritance problem

    hi, i'd like to know why
    oIdee->mIdTravail = null;
    in this case

    Code:
    abstract class Objet_Modifiable{
    	public $mIdBd;  	      
    	public $mIdTravail;     
    	
    	
    	function __construct(){
    		$this->mIdBd          = -1;
    		$this->mIdTravail     = -1;
    	}
    }
    
    
    
    class Redaction_Idee extends Objet_Modifiable{
    	private $mTitre;
    	private $mEstDesactive; 
    
    	//Constructeur
    	function __construct(){	   
    		 $this->mTitre         = "";
    		 $this->mEstDesactive = false;
    	}	
    }
    I create a new Idee object :

    Code:
    $oIdee = new Redaction_Idee();
    var_dump($oIdee);
    the var dump shows that both $mIdBd and $mIdTravail are NULL even tho I use a constructor to initilize the values.
    what's wrong with my basic thinknig?
    Last edited by Jahren; 01-15-2010 at 08:13 PM.

  • #2
    Regular Coder
    Join Date
    May 2009
    Posts
    143
    Thanks
    14
    Thanked 1 Time in 1 Post
    oh wow...
    I did not know I had to implicitly call

    parent::__construct();

    even without any arguments.
    Sorry about that!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •