I like that but never done it , could you explain in detail?
a User Defined Type (UDT for short) would be either a struct, union, class or enum.. Stay away from unions unless you have any good reason to use one, and enums are for numerical values, which leaves you with struct and class (Note - class is C++ only).
in C++, struct and class are both actually the same thing... well, almost.. they have one minor difference which isn't important at the moment.
a struct (the name originally came from 'data structure') is conceptually very similar to a table layout in an MS Access database - in fact, I suspect that most databases use the term "data structure" too.
At the basic level, it will typically contain one or more "fields" (called member variables), and every record (object) created has its own value for each of these fields.
eg,
struct MyStruct
{
std::string foreame;
std::string surname;
char middleInitial;
int age;
}
int main()
{
MyStruct MyPerson;
MyPerson.forename = "Fred";
MyPerson.surname = "Bloggs";
MyPerson.middleInitial = 'E';
MyPerson.age = 36;
// etc.
}
You can make an array of UDTs in exactly the same way as you'd create an array of int or any other built-in type. ie,
MyStruct PeopleDatabase[50];
PeopleDatabase[0].forename = "Joseph";
Note - above is C++ code, C uses a slightly different syntax for creating an object of MyStruct. If you are using C++, then this is probably your first step into writing Object-orientated code.