4

Possible Duplicate:
What is the difference between a definition and a declaration?

Is it correct that to declare in C is equal to define in C++?

int a;     /* to declare variabel a in C */
int b = 2; /* to declare and initialize in C */


int c;     // to define in C++ 
int d = 4; // to define and initialize in C++ 
Community
  • 1
  • 1
Chris_45
  • 8,769
  • 16
  • 62
  • 73
  • 2
    Dupe of http://stackoverflow.com/questions/1410563/what-is-the-difference-between-a-definition-and-a-declaration – Prasoon Saurav Jan 25 '10 at 12:30
  • _Is it correct that to declare in C is equal to define in C++?_ No,that makes no sense.Declaration and Definition are two different terms. Every definition is a declaration but every declaration is not a definition. For more info click the link that I have given. – Prasoon Saurav Jan 25 '10 at 12:33

3 Answers3

2

No.

For functions, I've seen "declare" being used for just writing the header, whereas "define" was used for writing the body.

However, it's all natural language. "declare" as in you C example seems correct for both C and C++.

user231967
  • 1,935
  • 11
  • 9
1

In C, declaring means to tell the compiler it exists whereas defining is assigning an actual value to it.

I see no reason why this would be different in C++

0

yes it should be

ufukgun
  • 6,889
  • 8
  • 33
  • 55