Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
3 answers
133 views

I have two questions. MY CODE: #include <stdio.h> void arrayFonk(int *dizi, int size, int *minimum, int *maximum){ int i; int b; for(i = 0; i < size; i++){ if(*(dizi ...
Game of HB - YT's user avatar
0 votes
1 answer
101 views

My Setup I have these things setup, A struct A templated function pointer that takes that struct as parameter with T as return type A templated method invoker that takes the callback of the function ...
dluffy121's user avatar
2 votes
0 answers
58 views

In my function I need to rotate a VecDeque a certain amount of times, always in the same direction that depends on the input, with a value that never changes. So I started envisioning a solution like ...
rdxdkr's user avatar
  • 1,275
1 vote
1 answer
84 views

From my reading, I understand that it is possible to compare some pointer types in C++ using either operator< or std::less. This is useful if, for example, a pointer is used as a key for a std::...
Patrick Wright's user avatar
4 votes
1 answer
233 views

I am learning C++ using the book "C++ Primer" by Stanley. In particular, the section about "pointer conversions" says: a pointer to any nonconst type can be converted to void* ...
user avatar
1 vote
1 answer
123 views

Consider: void f(int); // (1) void f(int, int); // (2) auto pf1 = static_cast< void (*)(int) >(f); // Ok, address of (1) auto pf2 = static_cast< void (*)(int, int) >(f); // ...
Hank's user avatar
  • 342
0 votes
1 answer
135 views

In my code, I want to set pointers to OpenBLAS subroutines, to compile the code either in single or double precisions. To do so, I define two modules and I define function interfaces for single(sgemv) ...
Navid Khairdast's user avatar
0 votes
1 answer
75 views

I have 2 classes: MeshInput and VoxelGrid. VoxelGrid has the member sdf which is a function pointer. Now I want to assign a non static function of another class to sdf. I can't change the signature of ...
conixtract's user avatar
0 votes
2 answers
100 views

I am trying to familiarize myself with pointers to functions in C. I have looked online and found several examples of these. However, when I compile my program (using GCC [version (Debian 12.2.0-14) ...
Stuart's user avatar
  • 133
3 votes
2 answers
120 views

I'm using an array of functions pointers, and I'd like to use it directly with their associated event IDs. Problem is, event IDs start from 0x10 to 0x1C, and from 0x90 to 0xA5. I don't want to write ...
mescande's user avatar
1 vote
0 answers
96 views

I am writing code that starts in Python, then goes to C via ctypes and inside C it uses Python embedding to invoke a Python function, that is, the flow looks like this: Python user code passes ...
Dmitry Kabanov's user avatar
2 votes
2 answers
111 views

I was trying to get "more fluent" with function pointer manipulation and I've got an issue with passing a member function to std::function when there are two overload: const and non-const. ...
Oersted's user avatar
  • 3,732
1 vote
2 answers
67 views

Topic: Given a positive integer with no more than 5 digits, require: Find out how many digits it is; Output each digit separately; Output each digit in reverse order. For example, if the original ...
Navy Zhang's user avatar
2 votes
0 answers
64 views

I try to call few shared object functions from Go. I don't want to write a C commented code to build a CGO interface for all functions. I write my shared object like that: #include <stdio.h> ...
MauriceLambert's user avatar
1 vote
1 answer
110 views

I've written the following class that looks up a keyword and executes the associated function. #include <iostream> #include <string> #include <map> class Example; typedef std::map&...
cup's user avatar
  • 8,538
0 votes
1 answer
42 views

I have problems using a struct as an argument in the declaration of a function pointer (MyFunction) below: #include <iostream> struct Record { int x, y; }; // MyFunction returns a changed ...
Niels Holst's user avatar
-1 votes
1 answer
87 views

TLDR: How does std::bind() actually work when calling a member function with an instance of a class or a this pointer of the class? Notes: I know what a function adapter and a function object are. I ...
LiuYuan's user avatar
  • 493
-5 votes
3 answers
335 views

I am looking for optimizing my update loops, and got around to this code: // Define two lambda functions auto iftrue = [](int x, int y) -> int { return x; }; auto iffalse = [](int x, int y) -&...
ingotangjingle's user avatar
0 votes
0 answers
38 views

#include <list> #include <vector> #include <mutex> typedef std::list<void *> funcList; typedef struct { funcList* functionsList; char* listName; }ListAccess_t; namespace ...
chandu's user avatar
  • 85
0 votes
2 answers
111 views

I have problem in this line std::cout << &X::a << std::endl; this line print 1 supposed to printed address of &X::a this my code #include <iostream> #include <string>...
Hassan Lakhal's user avatar
1 vote
1 answer
329 views

let's say I have a function that accepts a callback argument (example given in rust and C) void foo(void (*bar)(int)) { // lots of computation bar(3); } fn foo(bar: fn(u32)) { // lots of ...
ajp's user avatar
  • 2,575
-1 votes
1 answer
50 views

I am getting compile error C2064 for this code. class MainClass; class MyClass { public: MyClass(); void (MainClass::*functionPointer)(); void callback(); }; class MainClass { public: ...
lugshout's user avatar
3 votes
4 answers
174 views

I was wondering why both versions of this code have no error: #include <iostream> bool check_number(int n) { return n < 5; } int main() { int number = 6; // (1) prints "...
Freddie99's user avatar
1 vote
2 answers
240 views

In The C Programming Language (Kernighan and Ritchie, 2nd ed) on p147, the authors show a typedef declaration typedef int (*PFI)(char *, char *); (PFI stands for "pointer to function returning ...
Lover of Structure's user avatar
-1 votes
2 answers
107 views

Here is the program as text: #include <stdio.h> int f(int x){ return x+1; } int main() { int (*p)(int) = f; printf( "%d\n", sizeof(p) ); printf( "%d\n", ...
Anuj Yadav's user avatar

1 2
3
4 5
90