Delphi, how to control function pointers during assignment? I.e. Storing value of pointer instead of calling pointer?

Advertisements This seems like a basic question, but I tried searching and couldn’t find an answer. I have a function pointer declared like this: THandleTableCellEdit = function(InitValue, FileNum, IENS, FieldNum : string; GridInfo : TGridInfo; var Changed, CanSelect : boolean; ExtraInfo : string = ”; ExtraInfoSL : TStringList = nil; Fields : string = ”;… Read More Delphi, how to control function pointers during assignment? I.e. Storing value of pointer instead of calling pointer?

Passing pointers of vectors with structures C++

Advertisements I’ve declared the following function in C++ void setCellInfo (CELL_MESH* target, int Global_ID, int node0,vector<NODE_MESH *>* NodeStore, vector<CELL_MESH *>* CellStore) { CellStore->push_back(target); //No Errors target->Global_ID = Global_ID; //No Errors if (node0 != 0) { target->node[0] = NodeStore[vector<NODE_MESH *>::size_type(node0)]->ID; //ERROR 1 target->node_pointers[0] = NodeStore[vector<NODE_MESH *>::size_type(node0)]; //ERROR 2 } } ERROR1: Gives me a "No member… Read More Passing pointers of vectors with structures C++

Why does having a int* (float) point to a int() have a warning, but int* (double) don't?

Advertisements I have this piece of code: int foo(){ return 0;} int main() { int (*float_function)(float) = foo; } Compile using x86-64 gcc 12.2, with -Wall, it produces the warning (Link): warning: initialization of ‘int (*)(float)’ from incompatible pointer type ‘int (*)()’ [-Wincompatible-pointer-types] but when I change from float to double (Link): int foo(){ return… Read More Why does having a int* (float) point to a int() have a warning, but int* (double) don't?

Do I have to initialize function pointers one by one?

Advertisements When I initialize function pointers in one take, like below, it does not work. ptr[3]={add, subtract, multiply}; This gives: [Error] expected expression before ‘{‘ token However, one-by-one initialization works. Why is this? //array of function pointers #include<stdio.h> void add(int a, int b){ printf("%d\n", a+b); } void subtract(int a, int b){ printf("%d\n", a-b); } void… Read More Do I have to initialize function pointers one by one?

Member Function Pointer Giving multiple errors

Advertisements I have a member function pointer inside of my MethodPtr class. That’s public and is declared like this: void (Method::*func)() = nullptr; It’s giving me multiple errors and I’m unsure why. These errors are ‘func’: unknown override specifier ‘Method’: is not a class or namespace name ‘methodptr’: unkown override specifier missing type specifier syntax… Read More Member Function Pointer Giving multiple errors

std::function Error : error: static assertion failed: Wrong number of arguments for pointer-to-member?

Advertisements I have a tricky problem and I’m working on it for several hours but can’t find a cause and solution of it. Hope someone help me. I have to demonstrate function being called inside another function( pls see the comment in seminar.cpp) Below are the files ( I have separated it into header and… Read More std::function Error : error: static assertion failed: Wrong number of arguments for pointer-to-member?

I keep getting an error when working with pointers in C

Advertisements I’m writing a program in C which has a container (linear linked list) which contains char arrays as its data. I’m required to write a function firstItem(container* containerADT) which returns the the struct variable top. I’ve tried writing the firstItem function many times in many different ways and I keep getting the same error.… Read More I keep getting an error when working with pointers in C