Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
Filter by
Sorted by
Tagged with
-1 votes
1 answer
21 views

my code looks like this: //Renderer.h file #pragma once class Renderer { public: static int Test(); }; //Renderer.cpp file #include "../Header/Renderer.h" #include <iostream> int ...
Reska's user avatar
  • 17
0 votes
2 answers
164 views

I am trying to adapt this PipeWire example for use with C++, as I need to carry out various processing in a C++ method. But I am not sure how I can call a C++ member method from the static callback ...
Loke's user avatar
  • 19
0 votes
0 answers
50 views

I came across with a C++ code that is vague for me due to the way of access to static function member of a class. Basically, static function members must be accessed using scope resolution operator(::)...
hsn hejazin's user avatar
0 votes
1 answer
124 views

I found these lines in a header file (https://github.com/eyalroz/printf/blob/master/src/printf/printf.h) that is part of a printf implementation. // If you want to include this implementation file ...
EmTor's user avatar
  • 165
0 votes
1 answer
112 views

What's the difference between these two non-member functions ? static void function1() { std::cout << "Test" << std::endl; } void function2() { std::cout << "...
Autechre's user avatar
  • 633
2 votes
2 answers
3k views

class A { public static int f1() { return 1; } public static int f2() { return A.f1(); } } class ATest { @Test void testF2() { try (MockedStatic<A> ...
Samir's user avatar
  • 4,243
0 votes
2 answers
70 views

I defined the next two static functions in a file named Grafico.h. static inline interface_t * obtener_intf_por_nombre(nodo_t *nodo, char *nombre_if) { for (int i = 0; i < MAX_INTF_POR_NODO; ++...
EmTor's user avatar
  • 165
0 votes
1 answer
673 views

There are many functions in CRT library marked as static. How it will be imported in modularized project? Here is the code reproducing the problem. Header.h static auto foo() -> void {} ...
Serge Kork's user avatar
0 votes
1 answer
816 views

I am trying to resolve the checkmarx issue which says application embeds untrusted data in the generated output.This untrusted data is embedded straight into the output without proper sanitization or ...
mohit_basantani's user avatar
0 votes
1 answer
1k views

I'm very new to c++ and I'm creating a Task List for a project, and I keep getting this error on both static functions within "TaskIO.cpp" when I try to run the code. The goal of the ...
Agamer199's user avatar
1 vote
1 answer
498 views

class User { private static $User; public static function get() { if (empty(self::$User)) { echo "Create New Object<br/>"; return self::$...
Hamza's user avatar
  • 11
0 votes
1 answer
298 views

public class C { public static string a; public static string b; public C(String a, String b){ this.a=a; this.b=b; } public void addString(){ String result=a+b; } public static JSONObjet ...
lily's user avatar
  • 1
1 vote
1 answer
5k views

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 ...
codeLover's user avatar
  • 3,860
0 votes
2 answers
1k views

I have a static function in a source file that is used by other functions in that same source file. Is it fine to put the declaration for that static function in the header file, even though that ...
user avatar
7 votes
1 answer
10k views

I've been reading a bit about static functions and static member functions. From my understanding if a function is declared static then this function is only visible to it's translation unit and ...
user8469759's user avatar
  • 2,948
1 vote
2 answers
2k views

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("...
hasnain nadeem's user avatar
1 vote
3 answers
207 views

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 ...
Tilak_Chad's user avatar
0 votes
1 answer
97 views

I have a base class with a static function. But I would like to have a way to know the actual class (could be the base class or a derived class) within whose context I am calling the static function. ...
RocketNuts's user avatar
  • 11.4k
2 votes
2 answers
320 views

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 { ...
ImanX's user avatar
  • 816
-2 votes
1 answer
188 views

// Ive found useful information in other questions relating to static variables and their initialization. I found a work around (didnt feel like solving this with a separate file as suggested here: ...
Samuel Franco's user avatar
0 votes
1 answer
140 views

In my C++ class, I have two static methods, called getInstance. The method declarations are as follows: public: // +++ STATIC +++ static CanCommunicator* getInstance(shared_ptr<ThreadState>...
SimonC's user avatar
  • 1,637
0 votes
1 answer
91 views

I'm writing a library in c and there are some functions I would like to be callable from other c file and some I would like to keep private. I know that it is possible to hide functions outside of ...
Luca's user avatar
  • 67
13 votes
2 answers
3k views

If I define a function in my program.cpp: constexpr bool isThree(const int number) { return number == 3; } is that any different from declaring it static? static constexpr bool isThree(const int ...
Tomáš Zato's user avatar
  • 53.9k
3 votes
1 answer
1k views

I'm working with a legacy library which allows me to call a C function in response to some event. I can not pass parameters to the C function. I want the C function to raise the event to Objective-C ...
Alex Stone's user avatar
  • 47.4k
0 votes
2 answers
134 views

I would like to define a property in a static class, then access to this property from another static class. For this aim I have defined such a property: public static class First { public ...
Kaja's user avatar
  • 3,087
0 votes
1 answer
127 views

my code of AvlTree class head file is as follows: template <typename T> class AvlTree { public: template <typename T1> friend class AvlNode; AvlNode<T> *root; ...
Tseng Fansgou's user avatar
3 votes
1 answer
3k views

I have class whose header file is defined as: namespace mip { class CustomStatic { public: static const char* GetVersion(); }; } And class file is defined as: #include "...
Abhijeet srivastava's user avatar
0 votes
2 answers
271 views

I have static member function inside my class which I would like to add in my namespace. class A{ public: static void func(); }; namespace myNamespace{ void A::func(){ ... } } int ...
Naor Sasson's user avatar
1 vote
1 answer
183 views

I have a basic class that containers two enumerators, one for input and one for output. It has two member functions which are both static. The first function is just a static function that returns a ...
Francis Cugler's user avatar
1 vote
1 answer
179 views

To implement unit testing for one of my programs, I've added a makefile rule to build the program as a static library when "make check" is run. I wrap main() with #ifndef TEST_LIB and #endif (TEST_LIB ...
Andy Alt's user avatar
  • 446
1 vote
2 answers
1k views

I was reading about static functions and it was said that if the function is static then you can use it only in the same file. After testing it, I realized it is not true because if you include the ...
Vegeta's user avatar
  • 330
0 votes
3 answers
2k views

everyone! there is a code snippet like the below: testcase.cpp #include <string> #include <iostream> using namespace std; class Test { public: static int b ; static void test() ...
luoyu mo's user avatar
0 votes
3 answers
208 views

I know that C++ compilers optimize empty (static) functions. Based on that knowledge I wrote a piece of code that should get optimized away whenever I some identifier is defined (using the -D option ...
SX.'s user avatar
  • 91
0 votes
2 answers
3k views

I have this static function written in swift that I need to call in objective-c file static func downloadVideo(url: String, onResult: @escaping(String?) -> ()){ //some code onResult("done")...
redike's user avatar
  • 15
-1 votes
1 answer
723 views

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 &...
Alok's user avatar
  • 137
1 vote
1 answer
2k views

I am learning about static function and as per rule if i declare function as a static function then i can't access this function into other c file and if i try to access then there should be an error ...
user374112's user avatar
21 votes
2 answers
13k views

My version (5.4) of gcc warns about unused static functions, even in a header file when -Wall is used. It doesn't complain if the same functions are defined static inline or simply inline. For ...
BeeOnRope's user avatar
  • 66.3k
1 vote
1 answer
78 views

I was given the the following main function and I have to code the object to pass. Here's main: #include <iostream> #include <string> #include <ctime> #include <stdexcept> #...
NBell's user avatar
  • 11
0 votes
0 answers
97 views

In C or C++ you can declare a function to be static if it is only used in a single Translation Unit (i.e. file), for example: static int square(int a) { return a * a; } This should allow the ...
Timmmm's user avatar
  • 99.1k
1 vote
3 answers
191 views

How can I call static function inside the class itself? I try self keyword instead of this but I still get error. class Test { static staticFunction() { console.log('Inside static ...
quarky's user avatar
  • 748
0 votes
2 answers
301 views

Why this is not allowed in unevaluated context in static member functions? struct A { void f() {} static void callback(void * self) // passed to C function { static_cast< ...
Tomilov Anatoliy's user avatar
0 votes
0 answers
67 views

I need to get all C/C++ functions names from disassembled library of android NDK project. Now I see only not static functions. Is there a possibility to include static functions to symbols table? I ...
Darya's user avatar
  • 3
1 vote
2 answers
3k views

I'm trying to set a reference of a non-static function in c++. The function I'm referencing is not from the same c++ file, and I get and error saying : Cannot create a non-constant pointer to ...
LearningThings2's user avatar
0 votes
2 answers
619 views

Hopefully this is not a duplicate of a number of other questions relating to the meaning of 'static' functions in C. We support some legacy native C code containing things along the following lines .....
Justified's user avatar
0 votes
0 answers
67 views

I'm new to React. Can somebody explain why ES6 is launched without any mixin support. Since, there is no support for mixins when you use React with ES6 classes. Can we use Static functions instead of ...
Karan Jariwala's user avatar
0 votes
2 answers
73 views

fileA.c has a static function (static int funcA()) The fileA.c can not be modified. fileB.c How can I use the funcA()?
Cena's user avatar
  • 1
-2 votes
1 answer
557 views

I write a project with visual studio. In the project I build a class called CSimApplianceDlg which has two members: static UINT RecvDataFrame(LPVOID pParam) and CSerialPort m_Port class ...
pellyhawk's user avatar
0 votes
0 answers
74 views

EDIT:thanks for pointing me in the right direction of circular dependency. I tried removing #include "datastructure.h" from Mathfg.h, and I added a "Class ArithmeticTree" in "Matfg.h" to forward ...
Dexter André's user avatar
0 votes
1 answer
1k views

I am building a qt application in which i am have to access ui elements. but i am getting error as invalid use of member 'foo::ui' in static member function The code is big so cant add here. ...
RPK's user avatar
  • 53
1 vote
4 answers
1k views

Say I have the following class: class Test { private static $instance = false; public static function test() { if(!self::$instance) { self::$instance = new ...
Erdss4's user avatar
  • 1,155