Jump to content

Recommended Posts

Hi,

 

I am new to OOP and got the bitter tast right now.

 

i created two class let name be class A and Class B.

 

Class B - has a method with variable

 

class B{

        function something($var1, Var2)

        {

              ...............

        }

}

 

Now i used this class in class A

 

class A{

 

        function nextthing(){

              A::something($var1, Var2)

              .....................................

          }

}

 

 

Now i get error message "Undifine $var1 & $var2" when i run it thru other file,

 

How can i solve this problem.

maby in your parent class use a accessor method ie (set and get method) to set your data members. and then extend the parent class with a subclass. and access them through the subclass which would extend the patent class through inheritance.

 

now you could set up a constructor in you parent class to set your data members OR just invoke your methods to set them so they can be accessed.

 

failing that maby read up on OOP more in depth

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.