I noticed that you can declare a pointer to a struct in two ways:
struct spell * spells;
and
spell * spells;
what is the difference?
I noticed that you can declare a pointer to a struct in two ways:
struct spell * spells;
and
spell * spells;
what is the difference?
In C, struct
keyword must be used for declaring structure variables, but it is optional in C++.
For example, consider the following examples:
struct Foo
{
int data;
Foo* temp; // Error in C, struct must be there. Works in C++
};
int main()
{
Foo a; // Error in C, struct must be there. Works in C++
return 0;
}
Example 2
struct Foo
{
int data;
struct Foo* temp; // Works in both C and C++
};
int main()
{
struct Foo a; // Works in both C and C++
return 0;
}
In the above examples, temp
is a data member that is a pointer to non-const Foo
.