When you come to think of it, they are hard to descirbne, so ill give an example. Say I wanted to record loads of enemies for darkGDK, say space ships. now each of these ships needs a speed, a direction, and a weapon, as well as an integer to connect it to the GDK model. It needs to be updated every frame.
We can use a class to hold all this data, something like this:
class enemyShip{
public://stuff in here can be accessed externally
int gdknum;
float speed;
D3DXVECTOR3 direction;//direction vector. This is a dx struct, you should probably ignore it if you dont understand it
enemyWeapon weapons[10];//array of ten of the enemyWeapon class. example of nested objects.
void update(float rotation, float acceleraton);//function prototype.
enemyShip();//constructor
~enemyShip();//destructor
//read a proper tutorial for infor on these
}
Now we can use this class as if it were a datatype:
enemyShip myenemy1;
enemyShip *enemypointer;
enemyShip enemyarray[50];
To access members of these
objects, we use the . operator, or for pointers, ->
EG:
myenemy1.speed = 100.0f;
enemypointer->speed = 5.556;
enemyarray[5].update(50.0f, -10.0f);
A struct is like a class, except that it contains no functions, only values.