Questions tagged [static-functions]

124 questions
2
votes
2 answers

Can functions accept static function pointers as arguments?

Here's a good example: I'm trying to overload OpenGL's glutMouseFunc so it may accept the namespace, and class function of my choosing. The one in particular is Init::DisplayInit::mouse, which is static. The question is, is this possible? If so, how…
zeboidlund
  • 9,731
  • 31
  • 118
  • 180
2
votes
2 answers

How to refer overriden class functions in python

I know C++ and Java and I am unfamiliar with Pythonic programming. So maybe it is bad style what I am trying to do. Consider fallowing example: class foo: def a(): __class__.b() # gives: this is foo bar.b() #…
Johu
  • 626
  • 7
  • 15
2
votes
2 answers

How to declare an extension static function in Kotlin on Java Classes?

I want declaring an extension func in kotlin but on Java classes Library, I know that do in Kotlin when you resolve companion in extension function. Like: class Food { companion object { fun foo() = Unit } } fun…
ImanX
  • 789
  • 6
  • 23
2
votes
3 answers

How static function is accessing private member function(constructor) of a class

I came across code like the below, which is basically an example of a singleton class in which we make the class constructor private and provide one static public function to create an instance of the class when required. My question is when we call…
Jack
  • 694
  • 8
  • 20
2
votes
2 answers

call a non static function in a static function in laravel 5

i am using laravel 5. And in a model i have a static function which i am calling in controller. It's working fine but i want same changes in this function with another non static function and when i am calling it inside static function it produce…
Jitendra
  • 558
  • 8
  • 23
2
votes
3 answers

how to test static functions of C using google test

I have a C file contains some static functions, how to use google test to test those static function? header file: test.h int accessData(); source file: test.c static int value; static int getData() { return value; } int accessData() { …
ratzip
  • 1,571
  • 7
  • 28
  • 53
2
votes
3 answers

When did/does using #define to define a static function in C work?

Working in a new to me code base and I have come across some C code that looks like this: static int* functionA(int* anInt); #define functionA(anInt) ( ) Maybe this is obvious to people who’s C coding is a bit more fresh…
TafT
  • 2,764
  • 6
  • 33
  • 51
2
votes
1 answer

Function fails to execute in tag but works with LinkButton

I have a static class (SS.U) with a function (GP) that returns true or false. My problem is that this function is not triggered when I use it inside the tag, but works fine inside an asp:LinkButton tag. I need both of them for some reasons. Here…
Nurp
  • 1,409
  • 13
  • 25
2
votes
4 answers

reference to static function in PHP

is possible get reference to static function and run? like this: namespace vendor\foo; class Bar { public static function f1() { echo 'f1'; } public static function f2($id) { echo 'f2: '.$id; } } and $fs =…
seyed
  • 1,555
  • 1
  • 17
  • 24
1
vote
2 answers

JUnit Mockito: Testing a Static Method and Calling Another Stubbed Static Method Inside Not Working

class A { public static int f1() { return 1; } public static int f2() { return A.f1(); } } class ATest { @Test void testF2() { try (MockedStatic aStatic = Mockito.mockStatic(A.class)) { …
Samir
  • 3,923
  • 9
  • 36
  • 43
1
vote
1 answer

php static function class save previous function call data

class User { private static $User; public static function get() { if (empty(self::$User)) { echo "Create New Object
"; return self::$User = new User(); } echo "Already…
Hamza
  • 11
  • 2
1
vote
1 answer

C++: Static member function returning an object of self static for a class with private constructor

I've a C++ snippet as below. The "getInstance()" function is trying to return a static object of the same class "CAbc". This class has a private constructor so that objects of this class can't be created. While calling this function in main(), like…
codeLover
  • 3,720
  • 10
  • 65
  • 121
1
vote
2 answers

Calling Invoke within a public static function Unity

I'm getting an error that I don't understand. The simplified version of my code: using UnityEngine; public class RunLater : MonoBehaviour { public static void Do() { Invoke("RunThisLater", 2.0f); } public void…
1
vote
3 answers

Static member function and access operator

I was just looking through lvalue(Value categories) from cppreference.com and came across member access operator that specifies as : In Built in Access operator of type E1.E2 : 3) if E2 is a static member function, the result is an lvalue…
Tilak_Chad
  • 111
  • 3
1
vote
1 answer

Static variables release order

Please help, The problem: core dumps in following code: I have an abstract class SomeOtherClass, and have derived from it SomeOtherClassImpl. Here is the code which causes the trouble: class MyClass { public: void someFunction() { …
1 2
3
8 9