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
-2
votes
2 answers
Getting Previous declaration is here Error in C
Task: write a function to calculate the area of a square, rectangle, circle.
My code is right. IDK why I am getting this error complete error
#include
#include
int square();
float airclearea();
int rectangle();
int main(){
int…

numextrix
- 1
- 3
-2
votes
2 answers
Function error: expected ')' before 'char'
This is a program to create a table full of points, but i'm trying to separate in functions.
I am doing this because I will need to add more functions in the future using the variables x and tabuleiro. I'm getting the error in the title and I don't…
-2
votes
1 answer
Why is my function returning 1 and not the variable value?
I am new to C and learning it for my University course. I am learning about functions and have to create a function that doesn't have any printf or scanf in it, just a function that calculates how many days are in a week.
int main(days)
{
int…

lukemooreuk
- 11
- 3
-2
votes
1 answer
Can we declare pointer functions in C or this is something else?
I found this on geeksforgeeks
char *getString()
{
char *str = "Nice test for strings";
return str;
}
int main()
{
printf("%s", getString());
getchar();
return 0;
}
Output: “Nice test for strings”
I tried searching pointer functions but its not…

Joe Robin
- 105
- 2
- 5
-2
votes
2 answers
Why use "const *" before declaring a function argument in C?
what I mean by this question is why is "const" used before argument1 and argument2, couldnt it be just the argument declaration without const? what does const do to the argument? static bool example(const char * argument1, const char *…

User__1
- 21
- 3
-2
votes
1 answer
Fuction-definition not allowed RetailItem
I got some problem when run my coding. I got 2 separate file to create RetailItem class and create main. I create both in project.
Below are main.cpp
//main
#include "retailitem.h"
#include
#include
using namespace std;
using…

SisLove
- 1
- 1
-2
votes
1 answer
behaviour of implicit function declaration
I know it is wrong to use a function without prototype.
But when I was fiddling around, I came across this strange and conflicting behavior.
test1
#include
#include
void main(){
char c='\0';
float…

manifold
- 437
- 6
- 23
-2
votes
2 answers
What effect does const at the beginning of a non-member function declaration have?
Digging through MSDN, I ran into just another curious line:
// This function returns the constant string "fourth".
const string fourth() { return string("fourth"); }
The full example is buried here:…

sigil
- 815
- 8
- 16
-2
votes
2 answers
Default argument for 'bool&' in function declaration
If I have a function declaration as follows:
int Remove(Object *spl, Object1* parent,
int num, Object2* th = NULL, bool& proceed
);
I get an error that I need to declare 'proceed' becasue 'th' has a default argument. I…

ssn
- 2,631
- 4
- 24
- 28
-2
votes
1 answer
Necessity of declaration of function in c and cpp
From bruce eckel --" although u should always declare functions by including header file , functions declarations aren't' essential in c . Its possible in c but not cpp to call a function u havent declared. This is a dangerous practise because the…

sumit
- 87
- 1
- 7
-2
votes
2 answers
The meaning of template keyword in the function declaration
What has the meaning the "using of template keyword in the function declaration"?
In this example compiler errors with error: "func" is not a template function.
template
struct Window {
T value;
};
template void func(Window,…

Simon Hong
- 3
- 2
-2
votes
2 answers
How to pass a pointer as an array argument?
I have a third-party library, which has a function delared as follows:
void foo(const void* input, char output[1024]);
If I write something like this:
char* input = "Hello";
char output[1024];
foo(input, output); // OK
But I don't want to declare…

xmllmx
- 39,765
- 26
- 162
- 323
-3
votes
4 answers
Is there a better way to write a C# function that accepts multiple types?
Some context: I'd like to write a class where the main method for adding things to a collection is through a method (or methods) that are named Add (or something like that). And so the signature that seems best is params object[]. Internally, this…

lucidquiet
- 6,124
- 7
- 51
- 88
-3
votes
2 answers
11:14: warning: passing argument 1 of 'strcmp' makes pointer from integer without a cast
If I get rid of the function "int check(char inp)" and put its code in "main" the program runs fine. But when I try to make a separate function to check the input I get errors.
#include
#include
/*trying to create a function…
user15095227
-3
votes
2 answers
The using declaration and function default arguments
According to the C++ 17 Standard (10.3.3 The using declaration)
1 Each using-declarator in a using-declaration98 introduces a set of
declarations into the declarative region in which the
using-declaration appears.
and
10 A using-declaration is a…

Vlad from Moscow
- 301,070
- 26
- 186
- 335