0 like 0 dislike
52 views
in Computer Science by (1.0m points)
What is meant by Function declaration?

1 Answer

0 like 0 dislike
by (1.0m points)
Declarations introduce names in a program, for example the names of variables, namespaces, functions and classes. Declarations also specify type information as well as other characteristics of the object that is being declared. A name must be declared before it can be used; in C++ the point at which a name is declared determines whether it is visible to the compiler. You cannot refer to a function or class that is declared at some later point in the compilation unit; you can use forward declarations to get around this limitation.

Definitions specify what code or data the name describes. The compiler needs the definition in order to allocate storage space for the thing that is being declared.

Declarations

A declaration introduces one or more names into a program. Declarations can occur more than once in a program. Therefore, classes, structures, enumerated types, and other user-defined types can be declared for each compilation unit. The constraint on this multiple declaration is that all declarations must be identical. Declarations also serve as definitions, except when the declaration:

Is a function prototype (a function declaration with no function body).

Contains the extern specifier but no initializer (objects and variables) or function body (functions). This signifies that the definition is not necessarily in the current translation unit and gives the name external linkage.

Is of a static data member inside a class declaration.

Because static class data members are discrete variables shared by all objects of the class, they must be defined and initialized outside the class declaration. (For more information about classes and class members, see Classes.)

Is a class name declaration with no following definition, such as class T;.

Is a typedef statement.

Related questions

0 like 0 dislike
0 answers 92 views
asked Jul 8, 2018 in Pak. Studies by admin (1.6k points)
0 like 0 dislike
1 answer 58 views
asked Nov 9, 2018 in Computer Science by danish (1.0m points)
0 like 0 dislike
1 answer 104 views
asked Jan 4, 2019 in Geography by danish (1.0m points)
0 like 0 dislike
1 answer 45 views
asked Nov 22, 2018 in Chemistry by danish (1.0m points)
0 like 0 dislike
1 answer 56 views
0 like 0 dislike
1 answer 505 views
0 like 0 dislike
1 answer 534 views
asked Apr 5, 2019 in Computer Science by danish (1.0m points)
0 like 0 dislike
1 answer 89 views
0 like 0 dislike
1 answer 131 views
asked Apr 5, 2019 in Computer Science by danish (1.0m points)
0 like 0 dislike
1 answer 96 views
asked Apr 5, 2019 in Computer Science by danish (1.0m points)
Welcome to Free Homework Help, where you can ask questions and receive answers from other members of the community. Anybody can ask a question. Anybody can answer. The best answers are voted up and rise to the top. Join them; it only takes a minute: School, College, University, Academy Free Homework Help

19.4k questions

18.3k answers

8.7k comments

6.3k users

Free Hit Counters
...