Hallo guten Tag,
weiß jemand was bei einer Deklaration und bei einer Definition bei einem C++ Programm passiert?
Also man hat am Anfang einen Spezifizierer und dann die Deklaratoren.
1 |
|
Ist das eine reine Definition ?:
1 |
|
Programming: Principles and Practice Using C++
Dort steht, dass
int a;// definition
eine Definition ist. Aber warum?
"A definition specifies exactly what a name refers to. In particular, a >definition of a variable sets aside memory for that variable. Consequently, you can’t define something twice. For example"
1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
Also bei der Deklaration wird dem Kompiler nur bekannt gemacht, dass ein Name mit einem bestimmten Typ und Eigenschaften vorhanden ist, aber es wird noch kein Speicherplatz allokiert?
https://code-better.com/declarations-prototypes-definitions-and-implementations-in-c/
A declarations merely tells the compiler how to use something, it does not >actually create anything.
DEFINITIONS: A definition fully specifies an entity. Definitions are where >the actual creation of the entity in memory takes place. All definitions >are also declarations, but not all declarations are definitions.
Danke