struct

From NWN Lexicon
Jump to navigationJump to search

A structure of different variable types combined into a single variable. Can be used with functions to decrease their complexity by returning many values at once. Values in the struct are set or retrieved using the dot (".") operator.

Example

// Struct definition
struct Name
{
    string First;
    string Last;
};

void main()
{
    // Struct declaration
    struct Name MyName;

    // Dot operator assignment
    MyName.First = "Bob";
    MyName.Last  = "Dobbs";

    // Dot operator access
    SpeakString("My name is " + MyName.First + " " + MyName.Last); // Say "My name is Bob Dobbs"
}

See Also

Struct Primer