Declaration is the part of the subprogram (procedure or function) which provides the protocol(header), but not the body of the subprogram.
Questions tagged [declaration]
3407 questions
1
vote
2 answers
Error: variable or field 'PrintEntity' declared void void PrintEntity(Entity e);
The code is really simple (but I am a newbie so I have no idea what I am doing wrong) :
#include
#include
void PrintEntity(Entity* e);
class Entity
{
public:
int x,y;
Entity(int x, int y)
{
Entity*…

Simone Verga
- 13
- 2
1
vote
1 answer
structure initialization failed
int main()
{
int i;
typedef struct {
int no[6];
int socket;
}data;
data *a = {
a->no[6] = {0},
a->socket= 3,
};
printf( "no[0] = %d\n",a->no[0]);
printf("socket = %d\n", a->socket);
…

pva18
- 21
- 3
1
vote
2 answers
Function to print out different members of an array (only two parameters are allowed)
The problem is to create a function that prints out n numbers of the array and their addresses. Function should be called 3 times in the main. The function can only have two parameters.
1. it will print all members of the array
2. it will print…

MaGK
- 17
- 4
1
vote
4 answers
type declaration and declaring struct in c
I have the following in the header file named vector.h
typedef struct coordinates coordinates;
Coordinates struct should have two variables. x and y
How can I include these two variables x and y without changing anything in header file?
my idea was…

rawwar
- 4,834
- 9
- 32
- 57
1
vote
1 answer
How to understand the const variable between different block scopes
I'm beginner in C++. I learned from the book "accelerated c++" about a const variable inside a block scope. It means that the "const variable will be destroyed when the scope ends at }.
But in the test: the const string variable s is defined inside…

liaohuguang
- 39
- 6
1
vote
2 answers
Passing a struct by reference errors( incomplete struct and redeclaration)
I'm trying to pass a struct by reference but no matter what I do I'm running into errors. I think I have the prototyping and declaration and the pointers all screwed up.
This is for an Arduino project of mine. The code works fine on the Arduino…

Micheal Double
- 81
- 5
1
vote
3 answers
Where are declaration and definition stored?
For a predefined function where are the declaration and definition stored?
And is the declaration stored in libraries? If so, then why it is named library function?

user11974307
- 13
- 2
1
vote
1 answer
Permitted usage context of declarations
The following code
#include
#include
#include
using std::cout;
using std::endl;
using std::unique_ptr;
using std::make_unique;
using std::boolalpha;
template
struct alloc{
alloc();
unique_ptr…

Vinod
- 925
- 8
- 9
1
vote
2 answers
Initialize array with function-depending size in C++
I'm writing a programm to create a roster. Every month has a different number of shifts, which is determined by a function. At the beginning of the programm the user enters the month, the according number of shifts gets calculated in a function and…

Nico
- 21
- 3
1
vote
1 answer
In C if I simply declare a variable without initializing it, will compiler reserve space for it?
In C if I simply declare a variable without initializing it, will compiler reserve space for it ?

shivam aggarwal
- 11
- 1
1
vote
4 answers
How to fix "conflicting types" for a function and its declaration?
I want to pass a two-dimensional char array to a function but don't know how to declare the function before the main(). The function compiles and works well before I declare it. But after I declare it, I encounter compiling issues.
I'm using EMACS…

Ty F
- 9
- 1
- 4
1
vote
3 answers
function declaration error, "expected constructor, destructor, or type conversion before ';' token"
I'm getting an error on line 4:
expected constructor, destructor, or type conversion before ';' token
I'm pretty weak at this point when it comes to functions, so I know that there is something wrong with my function declaration(?). Anyone have any…

Mrod
- 13
- 5
1
vote
1 answer
Global variable in header file without extern
Using global variable in header file we can change value/use variable in another file(same value can access/modify in multiple files), then why extern can be used ? What is difference between global and extern ?
Below is the example that i have…

Pankaj Suryawanshi
- 681
- 1
- 9
- 23
1
vote
5 answers
Why does fputs() require a constant as first parameter and not fputc()?
int fputc(int c, FILE *stream);
int fputs(const char *s, FILE *stream);
Why isn't const int c required in fputc()'s declaration?

user10471775
- 31
- 2
1
vote
1 answer
Implicit conversion of C pointer warning
I am using a linked list defined as follows:
typedef struct {
struct foo* next;
} foo;
Assuming that it has already been set up with the head pointer called linked_list and I want to iterate through the linked list as follows:
foo* curr =…

dd.
- 671
- 1
- 5
- 13