Questions tagged [static-functions]

124 questions
0
votes
1 answer

visual studio cannot resolve static functions

Here is the code and the output. win_main.cpp #include #include #include "d3d9_object.h" #pragma comment(lib, "d3d9.lib") #pragma comment(lib, "d3dx9.lib") LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); WNDCLASSEX…
sasha199568
  • 1,143
  • 1
  • 11
  • 33
0
votes
1 answer

In function overridding why we not declare it static

I have a child class where I define a static function: class functionover { function override($num1, $num2) { $total = $num1+$num2; } } class childfunctionover extends functionover { static function override($num1, $num2) …
Angle
  • 5
  • 4
0
votes
1 answer

How to calculate user input using non-static functions

My testing environment: Visual Studio 2010 Ultimate. the error I received: main.cpp(39): error C2352: 'Account::DepositAmt' : illegal call of non-static member function I've tried changing it to static functions but it only caused more…
SorryEh
  • 900
  • 2
  • 15
  • 47
0
votes
1 answer

Can I dynamically create a class name and then use it to call static function of that class in PHP?

I have two classes with the same static methods but each class has different implementation of the methods. In my code I know which static method I need to call, but the class type is determined dynamically. Something like this: class someClass_A { …
user2395238
  • 850
  • 1
  • 9
  • 20
0
votes
1 answer

What does prepending '&' to a function name mean in PHP?

I'm using a CMS package written in PHP. In one of it's core files I saw following line that is for defining a function in a class body. public static function &getLib($sClass, $aParams = array()) { // Code } I didn't understand why the function…
user4407686
0
votes
1 answer

How static member function can call the static private data member ? what kind of the internal transformation is needed?

Just imagine we have the following class: class A { private: static int m_a; public: A() {} static int get_sum(int b); }; int A::m_a = 5; int A::get_sum(int b) { return m_a + b; } int main() { // your code goes here A a; int c =…
user1886376
0
votes
4 answers

Call static function on deleted object

I'd start learning C++ and I don't understand this is memory leak or some kind of voodoo magic?! I have some "singleton" class (just for a demo): #include using namespace std; class S { private: S() { cout << "S::S" << endl; …
lxmarduk
  • 23
  • 2
0
votes
1 answer

Inline Static function and static variables

What is the use of making static function inline ? Rather than using the same function in two files ; is their any other use of static function? inline static int func(int a) { static int b; printf("Hello World !\n"); return…
Rohith Gowda
  • 137
  • 2
  • 2
  • 12
0
votes
1 answer

Static function within class, how will memory be handled?

I would like to use the following static function. This function will in turn compute the input, and std::cout a result. After the static function is called and taken off of the stack, will all of this memory associated with this class be freed? Is…
Algonomaly
  • 99
  • 1
  • 8
0
votes
2 answers

php static function run twice

I am new in studing php static function I want to build a function, curl some contents from some url, and then process php regex to get what I need. Here is my code, but the curl part runs twice. How to modify it so that short the run durante? $url…
fish man
  • 2,666
  • 21
  • 54
  • 94
0
votes
2 answers

C++ static functions and variables

I have written a class as shown below: #include using namespace std; class A { static int cnt; static void inc() { cnt++; } int a; public: A(){ inc(); } }; int main() { A d; return 0; } I want to call the function inc through the…
nitish712
  • 19,504
  • 5
  • 26
  • 34
0
votes
4 answers

Static member function with set parameters needs access to non-static data members

I have a static function that needs to access data members of a class. The function can be a member, non member or friend function of the class, but it must be static and it cannot take any arguments. So I cannot pass the data members to it as a…
cheezsteak
  • 2,731
  • 4
  • 26
  • 41
0
votes
2 answers

Android Static functions

I'm wondering how I can access the return statement with a static function. I have a static function with Async and I want to then get the return statement in another class - I know it sounds complex but, I'm sure it's an easy solution.…
TheBlueCat
  • 1,147
  • 5
  • 19
  • 38
-1
votes
1 answer

Trying to create object using constructor inside static function in C++

I was trying to create an object inside static function using a constructor. Here is the code class A { public: A() { this->a = 50; std::cout << "constructor called... " << this << std::endl; setAddr(this); } ~A() { this->a = 10; std::cout…
Alok
  • 127
  • 1
  • 7
-1
votes
1 answer

PHP: Access static function / method with object property

While I understand that static methods can be invoked through a variety of approaches, such as: A::staticFunction(); OR $class = 'A'; $class::staticFunction(); OR $a = new A(); // Assume class has been defined…
robnov
  • 1
1 2 3
8
9