A function declaration is the process of describing only the return type, argument types, and name of a function. This is required in some programming languages to use functions that were defined at a later point in the code or in another file. Use this tag for questions that pertain to or problems caused by forward declaring functions in languages that support or require doing so.
Questions tagged [function-declaration]
549 questions
0
votes
1 answer
How to declare an optional argument (mode) in the function(non_optional, mode="bla bla") in Python?
How to declare an optional argument in a function, that takes at least 1 real (non-optional) argument in Python?
Here's an example:
def myfunc(data, mode='never_mind'):
if mode == 'never_mind:
return
elif mode == 'print':
…

dizcza
- 630
- 1
- 7
- 19
0
votes
1 answer
Declaring a member function in C++
The following declaration of the function gives an error at compiling with g++:
void lfsr::rsa (int x, int y, int z, boost::dynamic_bitset<> initSeq(5))
The error is: expected ‘,’ or ‘...’ before ‘(’ token
And here is the whole code:
#include…

Mohamed Ahmed
- 457
- 1
- 7
- 25
0
votes
2 answers
c++ performing operations on functions and declaring functions
I want to declare a function for the following code which is a matrix that is read from a text file. The code can be seen below.
if (infile == "A.txt")
{
ifstream myfile("A.txt");
string line;
int MatA[3][3];
int i=0;
…

user3536870
- 249
- 1
- 2
- 13
0
votes
2 answers
Generate function pointer declaration at run-time in C++?
Is it possible to create/generate a pointer declaration similar to:
void (*foo)(int, float);
bool (*foo)();
char (*foo)(char, int);
But without knowing the type of the arguments or the return type until run-time.
The function declaration would be…

SLC
- 2,167
- 2
- 28
- 46
0
votes
2 answers
Function Definition Clarification in Matlab
I wrote some code that works just fine to evaluate theta on its own with some test input. However, I would like to take this code and turn it into a function that I can call within another matlab file. I keep getting the error message, "Function…

user3196474
- 35
- 5
0
votes
1 answer
Do function declarations in a prototype "pollute" the prototype?
What is the difference between this:
Library1 = function () {};
Library1.prototype.myFunc = function (p) {
function helper1(p) {return p * 2; }
function helper2(p) {return p * 4; }
this.result = helper1(p) + helper2(p);
}
and…

ciso
- 2,887
- 6
- 33
- 58
0
votes
1 answer
error in Function Decleration
I'm coding for stm32 microcontroller in Keil, 2 days ago I copied my source and header file in a project to TASKING, after some problems, all done but there is an error about all my functions declared in source and header files.
would please some…

Beh
- 35
- 2
- 6
0
votes
2 answers
function declaration and definition with double pointer in c++ giving error when switched from c to c++
I have switched to c++ from c. I have already done this kind of thing in c (Please don't dig the rest of the code for now just see the way of calling to functionfind_two_smallest(); it's definition in c and then below in c++ it's call. definition…

Sss
- 1,519
- 8
- 37
- 67
0
votes
1 answer
Caller property of JS for "foo = function()" style of coding
I want to use the property of "caller" for a function which is defined here
It works fine for this style of function declaration
function g() {
alert(g.caller.name) // f
}
function f() {
alert(f.caller.name) // undefined
…

arvind
- 117
- 1
- 3
- 11
0
votes
1 answer
How are functions inside functions called? And can I access those functions or they work like "helper methods"?
I'm studying Python through The Python Tutorial and I'm currently at Classes (chapter 9), but during the explanation of "scopes and namespaces" I got a question.
The author give this example:
def scope_test():
def do_local():
spam =…

Zignd
- 6,896
- 12
- 40
- 62
0
votes
3 answers
How to distinguishe declaration and use of a function?
I have the following structure in the code:
while (x > 0) {
something;
aaa::bbb::ccc some_name(
x,
y
);
}
I cannot understand what aaa::bbb::ccc some_name(. If it is a call of function, why do we need to specify its…

Roman
- 124,451
- 167
- 349
- 456
0
votes
2 answers
Function declaration with ternary operator
Is it possible to use a ternary operator to declare the function name?
var foo,
bar = 'bar';
(foo || bar) = function(){ // Invalid left-hand side in assignment [Bad assignment]
alert(true);
};
[foo || bar] = function(){ // Invalid…

yckart
- 32,460
- 9
- 122
- 129
0
votes
1 answer
Reference both earlier and later functions from other functions?
I've got a Lua script that presents an interactive text menu for configuring the script before actually doing the work. There is a main_menu() function, which has options the user can select, each of which call a different submenu() function. Each…

Sandwich
- 475
- 1
- 8
- 16
0
votes
2 answers
error C4430, C2143, and C2244 for a function in my template class
I'm trying to make a function that takes a templated type and adds it to the end of the list/array and I'm running into an error that I can't seem to find a way around. I'm new to templates so I'm not sure if it's a problem with how I'm using…

Ryan Taite
- 789
- 12
- 37
0
votes
1 answer
C++ member function not declared error, when it appears to be
I receive the errors:
cs163hw1.cpp:41:24: error: no ‘int menutype::run_prog()’ member function declared in class ‘menutype’
and
main.cpp:18:7: error: ‘struct menutype’ has no member named ‘run_prog’
When attempting to compile my program with…

Flexo1515
- 1,007
- 1
- 10
- 27