answersLogoWhite

Top Answer
User Avatar
Wiki User
Answered 2011-08-10 11:27:08

declaration is like a promise that somewhere else the thing in question will be actually defined.

001
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Your Answer

Related Questions


A declaration is an incomplete type whereas a definition is a complete type.


Definition. Example: extern int x1; /* declaration */ int x2; /* definition */ int x3= 2; /* definition with initialization */


within function call, declaration and definition


Something like this: program -> <empty> program -> type-definition program program -> type-declaration program program -> variable-definition program program -> variable-declaration program program -> function-definition program program -> function-declaration program


In C and C++, extern is a declaration of a variable or function, said declaration including the fact that the definition of that variable or function will occur in a different compilation unit, linking provided by the link editor or binder.


During function call and function definition and Declaration. These are the three places where arguments appear in C Program.


declaration examples:int main (void);extern int somevariable;definition examples:int main (void) { puts ("Hello world"); return 0; }int somevariable;


The term declaration is used when referring to variables. It means that the compiler is told about the type, name, as well as allocated memory cell for variable of a variable. The later action of the compiler, allocation of storage is called the definition of the variable. Example: Declaration of variable: extern int a; Definition of a variable: int a=5;


Actually, there is a third step, call definition. Declaration is a statement to the compiler of what type an identifier is, definition is the allocation of memory for that identifier, and initialization is the assignment of an initial value to that identifier. Usually, declaration and definition are done together, but you can also add initialization in that step if desired. int a; /* declaration and definition */ a = 1; /* initialization */ int a = 1; /* declaration, definition, and initialization */ For the case of seperate declaration and definition, consider the struct... struct _mystruct { int a; }; /*declaration */ struct _mystruct mystruct; /* definition */ struct _mystruct { int a; } mystruct; /*declaration and definition */ Note: To be more precise: struct _mystruct; /* struct declaration */ struct _mystruct { int a; }; /* struct definition */ typedef struct _mystruct MYTYPE; /* type definition */ extern struct _mystruct mystructvar; /* variable declaration */ struct _mystruct mystructvar; /* variable definition */ struct _mystruct mystructvar = {7} ; /* variable definition with initialization */ struct _mystruct { int a; } mystruct; /* struct definition and variable definition */ extern struct _mystruct { int a; } mystruct; /* struct definition and variable declaration */


definition: the meaning or description of person/place/thing declaration: taking a stand


== Yes. It may be funny. You cannot use keywords like newin c++ for variable declaration. But in C it is possible.== The following definition is valid in C, invalid in C++: char str [3] = "ABC";


different between defining value definition section and defining value declaration section


variable definition means to declare the variable with its value. for example:- int i=10; this statement is a combination of declaration of integer i and assign its value to it,so it is a definition statement Note: assigning a value is not essential.


parts of a programStructure of C++ programDocumentation SectionPreprocessor SectionDefinition SectionGlobal Declaration Sectionmain(){Declaration part;Executable part;}sub program section{Sub program execution part}


There is no difference, other than that declarations in C++ can also initialise the variable in a single instruction. C example: int x; // declaration x=5; // initialisation C++ example: int y=5; // declaration and initialisation combined.


actually ++ in c++ represents the advanced version of the language 'c'. Whereas c dont has any full form. In c ,c ++ means c =c +1 I think the question goes more to what "function definition" means. C++ (and many other languages) requires that that a function (any symbol really) must be known to the compiler before you actually try to use it. This is called the "function declaration" and simply specifies the signature of the function. The "function definition" then is the actual implementation of the function. You can declare and implement a function at the same time but normally you will split your source code into a header file (.h) containing the declarations and an implementation file (.cpp) containing the the definitions. For example: Declaration: class A { .... void doSomething(); } Definition: void A:doSomething() { // Your implementation here }


A function's declaration must be visible within every translation unit that uses that function, thus multiple declarations are permitted. To ensure consistency across all translation units that use a function, the declaration is usually placed in a header which can be included wherever it is needed. Formal arguments need not be named in a declaration (they do not form part of the function's prototype), but named arguments can provide better documentation and need not match the names used by the definition, or indeed by any other declaration of the same function. Note that a definition is itself a declaration, thus if a function is declared (but not yet defined), there has to be at least two declarations because the function must be defined somewhere. The "one definition rule" (ODR) implies there can only ever be one definition of a function, however multiple definitions are permitted provided those definitions appear in different translation units and are token-for-token identical (including the names of formal arguments). Being token-for-token identical means there is only one definition. Thus the correct answer is D: multiple declarations with one definition.



Perhaps an example will help. extern int value; /* declaration */ int value; /* definition */ int value= 20; /* definition with initialization */


// declaration: return_type function_name([argument_type_1[=value][, argument_type_2[=value][, ...]]]); // definition (function signature must match declaration): return_type function_name([argument_type_1 argument_name_1[, argument_type_2 argument_name_2[, ...]]]) { // implementation } In the case of separate declaration/definition, the definition file must include the file that contains the declaration unless they are both in the same file. If the function is a template function, both the declaration and the definition must be visible to the compiler BEFORE it can be used (thus they must both be in the same file). For all other functions other than inline expanded functions, only the declaration need be visible. Note that the definition is also a declaration, however default values must be omitted and all arguments must be named. The declaration arguments may also be named but they needn't match those in the definition (the definition names are the ones actually used). Alternatively: // combined declaration and definition: return_type function_name([argument_type_1 argument_name_1[=value][, argument_type_2 argument_name_2[=value][, ...]]]) { // implementation } Functions that are defined in the declaration are impicitly inline expanded. Functions that are defined separately must be prepended with the inline keyword in the definition, and the definition must be visible to the compiler BEFORE the function can be used. Functions that do not return a value must return void. If any other return type is specified, the function must explicitly return that type via all return paths. The main function must return an int, however return(0) is implied if not specified in the final statement.


Pieces of program-code, they are identified by their names. Example for function-declaration: int main (void); Example for function-definition: int main (void) { puts ("Hello, world!"); return 0; }


You understand a function by looking at its definition. The definition tells you exactly what a function does. The declaration (or the prototype) only tells you how to use the function. In other words, the declaration describes the interface to the function while the definition describes the implementation. In binary libraries where you only have access to the header, the definition may not be available to you (it will be obfuscated within the binary code). In that case you must look up the library documentation in order to understand the function.


Variable-declaration is: extern int x; extern double y; extern char a; Variable-definition is: int x; static double y; auto char a; Variable-definition with initialization is: int x = 1; static double y= 2.3; auto char a = 'w';


The question should be "what is ... definition ...?" It does not really matter where you declare a variable. Declaration is only a compiler directive telling it information about an object you intend to define later. Definition is what is important. Declaration and definition can be done at the same time, however; its just that they are two distinct actions. Global definition, now, is where the variable (or object) is defined at file scope, i.e. outside of any block, i.e. outside of any enclosing braces.With global definition, you have global scope, i.e. visibility. Unless you also specified static, you also have program scope, i.e. inter-module scope or visibility.


Yes. Often a pronunciation guide and a declaration of word type precede the definition.



Copyright ยฉ 2021 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.