G-Fact 12
In C, struct keyword must be used for declaring structure variables, but it is optional in C++.
For example, following program gives error in C and works in C++.
struct node { int x; node *next; // Error in C, struct must be there. Works in C++ }; int main() { node a; // Error in C, struct must be there. Works in C++ } |
chevron_right
filter_none
And following program works in both C and C++.
struct node { int x; struct node *next; // Works in both C and C++ }; int main() { struct node a; // Works in both C and C++ } |
chevron_right
filter_none
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Recommended Posts:
- GFact 22 | (2^x + 1 and Prime)
- GFact 23 | (Brocard’s problem)
- Can C++ reference member be declared without being initialized with declaration?
- Facts and Question related to Style of writing programs in C/C++
- Dilworth's Theorem
- Storage of integer and character values in C
- Vantieghems Theorem for Primality Test
- Cauchy's Mean Value Theorem
- Nesbitt's Inequality
- G-Fact 21 | Collatz Sequence
- G-Fact 20 (Cayley's formula for Number of Labelled Trees)
- G-Fact 17
- fseek() vs rewind() in C
- G-Fact 16
- What are the operators that can be and cannot be overloaded in C++?



