1 2 3 4 5
|
struct tm {
int tm_mon;
int tm_mday;
int tm_year;
};
|
This code, from your original posting, essentially announces to the compiler that there's this new kind of object. It's called a tm, and it's a struct. It has inside it these three integers.
That's all you've done. You haven't actually made one; you've just explained how to make one.
Recall how you make an integer object:
int aNewIntegerObject;
You write the type, and then the name you want to give the new object.
tm aNewInstanceOfTheStructure;
Now, you have an object of type tm, which is the structure, and it's called aNewInstanceOfTheStructure
Then, to access the internals of the structure, you would enter
aNewInstanceOfTheStructure.tm_mon = 7;
and now the tm_mon field of your newly created object has the value 7.