views:

37

answers:

2

Once in a while you stumble over a technical article where "creating" and "declaring" are used synonymously.

E.g.

declares an array of ints

creates an array of ints

But aren't declaring and creating two different things? Or does it depend on the context?

+2  A: 

In C and C++, the creation of an object also declares it:

int main() {
    int a[10];   // create a
    a[3] = 42;   // use a - no need for a separate declaration
}
anon
+1  A: 

The two are clearly separate, at least under some circumstances. Just for example, in C or C++, there are declarations that just declare things, and there are definitions that both declare and create them, and (only in C++) there are new expressions that create objects without declaring them (and, arguably, a malloc sort of does the same in C).

Likewise, in a language that supports lambda expressions, creation and declaration are separate -- a lambda expression creates something (e.g., a function) but doesn't (by itself) declare it (bind a name to it).

Jerry Coffin