static and non-static function
-
Hi all Can a static function call a non-static function inside the same class? or Can a static function call a non-static function in different class? Thanks
wow9999 wrote: Can a static function call a non-static function inside the same class? no or Can a static function call a non-static function in different class? no
-
Hi all Can a static function call a non-static function inside the same class? or Can a static function call a non-static function in different class? Thanks
-
Yes, no problem. As long as you have the object you wish to invoke the function. Tim Smith I'm going to patent thought. I have yet to see any prior art.
-
Dear Tim Smith can you show me a example or hint to see a static or non-static funciton to call a static or non-static function. Thanks
class Foo
{
public:
void Blah();static void Blech()
{
Foo f;
f.Blah();
}
};-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
-
Hi all Can a static function call a non-static function inside the same class? or Can a static function call a non-static function in different class? Thanks
A static method doesn't have a
this
reference. Hence, it can only call other static methods of its class. However, if the static method has access to an instance of a class, it can call that instance's static or non-static method.class Foo {
...
public:
static void staticFuncA();
static void staticFuncB();
void nonStaticFunc();
}void Foo::staticFuncA()
{
staticFuncB(); // OK
nonStaticFunc(); // invalid, since no "this" referenceFoo f;
f.nonStaticFunc(); // OK
}/ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com
-
Hi all Can a static function call a non-static function inside the same class? or Can a static function call a non-static function in different class? Thanks
1)Yes, if I pass to the function object of its class. 2) By a same way. ================================ Useful links