If I want to pass some class variable from one class to another : how
can I do it with the static function?
I tried but I can't see the class variables in the static function I
made-are there some other methods to do it?
Can you explain more in detail what you want?
Static functions are normally used to perform some operation without need of
the class to be instantiated because the static function does not use the
this pointer or any variable defined in the class. Basically you could see
these as the old style C functions.
Static variables are use to be used like global variables. This way you can
create multiple instances of this class, but they all point to that one
static variable.
So technically you rarely use static methods or variables.
Basically if you wish to pass on variables form one class to another class
then just assign them.
CClassA A = new CClassA()
CClassB B = new CClassA()
B.MyVariable=A.MyVariable.
If A.MyVariable is a basic type like int, float, then a copy is made.
If A.MyVariable is another instantiated class then the reference pointer is
copied, so both MyVariable wil point to the same instatiated object.
If A.MyVariable is another instantiated class but you do not want to have a
copy of that object and not the reference to that object then you do this:
B.MyVariable=new CMyVariable(A.MyVariable).
I hope this make sense?