Click to See Complete Forum and Search --> : Static Class and Static function


ye jing cheng yap keem siah
March 31st, 1999, 08:29 PM
Hi;

Just want to know who can i directly call and use a function from a class

without object or pointer. I heart it can be done bye Static class and static

function. ANyone tell me how to start with this?

Thanks...

phil
March 31st, 1999, 10:13 PM
You can use static functions just like you would use a global function. They are very similar.

Phil
March 31st, 1999, 10:13 PM
You can use static functions just like you would use a global function. They are very similar.

Ramon Saenz-Badillos
March 31st, 1999, 10:14 PM
to invoke a method without creating an instance of the class you need to

define the method as static. This makes the method belong to the class and

not to the individual objects of the class.

The _best_ way to use this static method is to use it without creating an

instance of the class, using <your_classname>::<your_method>

.

class your_classname {

public:

static void your_method();// static method declaration

//...

);

.

void main(){

your_classname::your_method();// static method invocation

//...

}

ye jing cheng yap keem siah
April 1st, 1999, 12:33 AM
Thanks...it work